#Basic Pycord Help
1 messages · Page 31 of 1
welchen
bezweifle ich ganz stark
das ich versuche avertar_url als bild zu laden
was es in pycord net gibt
weiß ich
was ist da ein bug
ist nur von der anderen lib die ich voher verwendet hab
das der command net klappt
ach bug bei dir? ja das glaub ich schon eher
/changelogs geht nun auch
scheint tarzächlich das importieren gewesen zu sein
aber nun werden die global geladen
die befehle
ist ungünstig für mich wenn ich dauernd sachen hinzufüge
Ja weils avatar_url net gibt? 💀
weiß ich
ich habs auch geändert geht wieder
dann ist das kein bug lol
immer wenn ich debug guild angeben laden die commands nert
äääääääääääh
seltsam
hat doch funktioniert, dann las auch die finger davon
falsche id?
ich will aber nicht die slash commands global laden

Zeig den code
prefix = "t."
bot = commands.Bot(command_prefix=prefix, intents=discord.Intents.all(), debug_guilds=[917174972588392499])```
so wirds geladen
ganz gruselig
wieso machst du den prefix so kompliziert
yea, man, dont ask me what even is going on
k.a.
Wenn du in dieser Gilde eine Ratenbeschränkung hast, kannst du für den Rest des Tages keine Befehle mit ihr synchronisieren; muss eine andere Gilde oder Global sein
also meinst du es ist serverseitig beschränkt
ja
hab ich zwar schon alles mal gesagt aber 
class verifyconfigmodal(discord.ui.Modal):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.add_item(discord.ui.InputText(label="Verification Question 1:", placeholder="ex. How old are you?"))
self.add_item(discord.ui.InputText(label="Verification Question 2:"))
self.add_item(discord.ui.InputText(label="Verification Question 3:"))
self.add_item(discord.ui.InputText(label="Verification Question 4:"))
self.add_item(discord.ui.InputText(label="Verification Confirmation Channel:", placeholder="Discord Channel ID Here..."))
channel = bot.get_channel(self.children[4].value)
question1 = self.children[0].value
question2 = self.children[1].value
question3 = self.children[2].value
question4 = self.children[3].value
async def callback(self, interaction: discord.Interaction):
await interaction.followup.send_message("Verification finished! Use /verifyconfig to edit!", ephemeral=True)
@bot.slash_command()
async def verifyconfig(ctx: discord.ApplicationContext):
modal = verifyconfigmodal(title="Set verification parameters here:")
await ctx.send_modal(modal)
There is no error message, and the modal says "something went wrong" when I try to submit
Is there something im missing?
Last time I encountered this problem, it was because an interaction message wasnt being sent
but this one is
class verifyconfigmodal(discord.ui.Modal):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.add_item(discord.ui.InputText(label="Verification Question 1:", placeholder="ex. How old are you?"))
self.add_item(discord.ui.InputText(label="Verification Question 2:"))
self.add_item(discord.ui.InputText(label="Verification Question 3:"))
self.add_item(discord.ui.InputText(label="Verification Question 4:"))
self.add_item(discord.ui.InputText(label="Verification Confirmation Channel:", placeholder="Discord Channel ID Here..."))
channel = bot.get_channel(self.children[4].value)
async def callback(self, interaction: discord.Interaction):
await interaction.response.send_message("Verification finished! Use /verifyconfig to edit!", ephemeral=True)
class MyModal(discord.ui.Modal):
def __init__(self, verifyconfigmodal, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.add_item(discord.ui.InputText(label=verifyconfigmodal.children[0].label, placeholder="ex. coolEp1cGamer69"))
self.add_item(discord.ui.InputText(label=verifyconfigmodal.children[1].label))
self.add_item(discord.ui.InputText(label=verifyconfigmodal.children[2].label))
self.add_item(discord.ui.InputText(label=verifyconfigmodal.children[3].label))
How can I assign the child values from the first class to the second one
what does that mean
I want to get the value of the input text in verfiyconfig and put that value as the label of the MyModal input texts
How are you planning to structure everything? What is the flow of this specific series of interactions?
a command is called and a modal shows, it has a couple input fields which when filled in and submitted, will be the labels of the input fields in a separate model, opened by a button.
What is this called the options parameter
in pycord
i saw this on another bot
and i want to know how to do this
where in the documentation shows how to make the options parameter
required=False
yw
Is this a bug or am I doing something wrong? I'm sending a webhook message and I'm setting the wait parameter as true to retrieve the WebhookMessage. But it appears that the data is lost.
Code snippet:
msg = await webhook.send(content, file=file, wait=True, username=f"@{acc.username}", avatar_url=img_url(acc.profile_image, resolution=180, crop_square=True))
print(msg.__dict__, type(msg))
Prints:
{} <class 'discord.webhook.async_.WebhookMessage'> # WebhookMessage appears empty
When I print out the webhook data inside the Webhook.send() function, it has the data but it appears to be lost when creating the WebhookMessage object.
Inside the Webhook.send() function:
msg = None
if wait:
print("data:", data)
msg = self._create_message(data)
print("\n__dict__:", msg.__dict__)
Prints:
data: {'id': '-----', 'type': 0, 'content': '"Placeholder Text" — via [RecNet](<https://rec.net/image/591913468>) — [@SleepySeal9376](<https://rec.net/user/SleepySeal9376>) — <t:1712992314:R>', 'channel_id': '-----', 'author': {'id': '-----', 'username': '@SleepySeal9376', 'avatar': None, 'discriminator': '0000', 'public_flags': 0, 'flags': 0, 'bot': True, 'global_name': None, 'clan': None}.....(shortened)
__dict__: {}
The webhook message is sent successfully.
Pycord version is 2.5.1.dev19+g59b9b32b (master branch), Python version is 3.10.11.
any particular reason for using the dev branch?
When I have a slash command with a option and the option has choices, is it possible that the user can't type something other than the choices? Like that the choices are only some examples what the user can type?
nope that not possible which choices
but i think with autocomplete its possible
choices got a limit of 25 items and can only be changed with a bot restart/ sync command
autocomplete dont really got a limit and it can get changed every time
what does the delete_messages_seconds and the delete_messages_days parameters in the member.ban() function means?
How many days/seconds of messages to delete
ok. thanks!
Doing some tracing it looks like this is a bug.
I have not worked with this part of the lib before but it looks like you have a local version of pycord that you can edit. Could you see if adding
wait: NotRequired[bool] to
pycord/discord/types/message.py Line 139 fixes your issue?
If that apears to fix the issue please tell me and I will try and craft a PR
Tried your fix and it unfortunately didn't fix the issue. Although I did some refactoring in my code so the bug doesn't affect me anymore.
https://github.com/pycord-development/pycord/pull/2402 This issue kept crashing my bot and the master branch has the fix.
I'm sorry this did not work, if you have time we would appreciate it if you made a bug report on GitHub. 😃
is there any particular reason you're using __dict__...?
we don't really keep raw data on models
Heyy, quick questions: are polls messages types supported in pycord v2.5? F. ex. for viewing a poll's fieldsfor moderation?
Just to show the the object is empty. I just realized that WebhookMessage doesn't have any attributes in the first place. I just assumed that it had Message's attributes since it's inherited. My bad.
Unless those attributes are meant to be accessed via WebhookMessage too..? It does return the WebhookMessage like intended.
Do the attributes actually not work when you access them
No, next release
my bad y'all
Allgood
There's an open PR for polls if you wanna use that
Just note stuff is subject to change
Should be fully finished on discord's end next week
I mean i'll maybe try and play around a bit just to be ready for the final release
If you ONLY need it for moderation, you can slightly modify message.py to add a poll attribute
I'll check the pr and see
it's just that I didn't find anything about that in discord's own docs as well, altough I might have missed it
alright
Is there a way to develop activities with py-cord?
Pycord is focused on bots creations
iirc activities use iframes which would mean they are better suited for JS
Thanks.
Are polls already availble?
Like toothy said it is only avalible on a incomplete PR. Everything should work but discord is still making changes on their side so things could break at any time as of now.
Ok. Thanks :)
So I've heard that creating a dictionary for decisions that are booleans with user_ids is a good idea.
I acknowledge the fact that those variables are temp and last only while the session is active but not sure what to do when bot is 24/7.
# I CREATED A SELECT MENU BY SLASH COMMAND, AND AFTER USER DECIDES TO NOT SPECIFY A REASON OF X, THE APPLICATION LISTENS FOR AN INPUT THAT IS A NEXT MESSAGE USER SENDS
[...]
discord.SelectOption(
emoji="🔗",
label="None of the above",
description="You'll need to give us a reason"
),
])
user_states = {}
async def select_reason(self, select, interaction):
match select.values[0]:
case "None of the above":
user_states[interaction.author.id] = True
@self.bot.event
async def on_message(message: Message):
if message.author == bot.user:
return
if user_states.get(message.author.id):
user_states[message.author.id] = False
save it elsewhere
also it might make more sense to take the user input through a modal
what even is that typehint in the if lol
yeah you're right I forgot this even exists
better than listening for inputs, and making some conditionals
it makes no sense
Ignoring exception in on_connect
Traceback (most recent call last):
File "/home/container/.local/lib/python3.10/site-packages/discord/client.py", line 400, in _run_event
await coro(*args, **kwargs)
File "/home/container/.local/lib/python3.10/site-packages/discord/bot.py", line 1178, in on_connect
await self.sync_commands()
File "/home/container/.local/lib/python3.10/site-packages/discord/bot.py", line 735, in sync_commands
registered_commands = await self.register_commands(
File "/home/container/.local/lib/python3.10/site-packages/discord/bot.py", line 534, in register_commands
desynced = await self.get_desynced_commands(
File "/home/container/.local/lib/python3.10/site-packages/discord/bot.py", line 357, in get_desynced_commands
elif _check_command(cmd, match):
File "/home/container/.local/lib/python3.10/site-packages/discord/bot.py", line 272, in _check_command
as_dict = cmd.to_dict()
File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 875, in to_dict
"options": [o.to_dict() for o in self.options],
File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 875, in <listcomp>
"options": [o.to_dict() for o in self.options],
File "/home/container/.local/lib/python3.10/site-packages/discord/commands/options.py", line 337, in to_dict
"type": self.input_type.value,
AttributeError: 'NoneType' object has no attribute 'value'
read the last line of the error
from dotenv import load_dotenv
import discord
from discord.ext import bridge
from mod import *
# Define the ID of the guild where the bot should work
TARGET_GUILD_ID = 1124466493204205689
intents = discord.Intents.all()
custom_activity = discord.CustomActivity(name="𝓤𝓷𝓲𝓽𝓮𝓘𝓷𝓭𝓲𝓪 𝓗𝓪𝓾𝓵𝓮𝓻𝓼 𝓑𝓸𝓽🚛")
bot = bridge.Bot(command_prefix='!', intents=intents, activity=custom_activity, status=discord.Status.dnd)
@bot.event
async def on_ready():
print("Bot is online")
print(f"Bot name: {bot.user.name}\n")
for command in bot.commands:
print(command.name)
# Check if the bot is in the target guild
guild = discord.utils.get(bot.guilds, id=TARGET_GUILD_ID)
print(f"Connected to target guild: {guild.name}")
# Get Discord bot token from environment variables
load_dotenv()
DISCORD_TOKEN = os.getenv('DISCORD_TOKEN')
bot.add_bridge_command(banned)
bot.add_bridge_command(unban)
bot.add_bridge_command(ban)
bot.run(DISCORD_TOKEN)
``` see this
it seems to be an internal error
cos of bridge
show your command definitions
are these actually in a class
no
then remove self
ok
(also tbh why not just make this a cog)
i will see to make in cog
is there a way in the name_localization to choose if it depend on the user_locale or guild_locale ?
it depends on the client's locale because that makes way more sense
and no, you cant change it
so its always about user_locale ok
is there a way to do that ?
class XP_Setup_View(discord.ui.View):
def __init__(self, bot, translator, author_id):
super().__init__(disable_on_timeout=False)
self.bot: commands.AutoShardedBot = bot
self.author_id = author_id
dropdown = discord.ui.Select(
placeholder=self.translator.xp.setup.panel.dropdown.placeholder,
options=[
discord.SelectOption(label=translator.xp.setup.panel.dropdown.mode.label, value="mode", emoji="🌐", description=translator.xp.setup.panel.dropdown.mode.description),
]
)
dropdown.callback = self.dropdown_callback
self.add_item(dropdown)
async def dropdown_callback(self, interaction: discord.Interaction):
if interaction.user.id != self.author_id:
return await interaction.response.send_message(translator.error.no_author, ephemeral=True)
(the translator i pass into the view can be used everywhere without having to do self.translator ?
Depending on the structure of your bot, if you have all the views in one file, you should just be able to put it into that file
or you import it from wherever you have that
depending what translator even really is
no the thing i was wanting to do was impossible
like put in the class and access without self
but that not a big deal whatever
changelog_embed = discord.Embed(title="Changelog von Planetbot V1.0.0 vom 27.01.24")
changelog_embed.add_field(name="🟢",value="/gutenmorgen",inline=True)
changelog_embed.add_field(name="🟢",value="/gutenacht",inline=True)
changelog_embed.add_field(name="🟢",value="/hello",inline=True)
changelog_embed.add_field(name="🟢",value="/countdown",inline=True)
changelog_embed.add_field(name="🟢",value="/cat",inline=True)
changelog_embed.add_field(name="🟢",value="/hype",inline=True)
changelog_embed.add_field(name="🟢",value="/roll",inline=True)
changelog_embed.add_field(name="🟢",value="/coinflip",inline=True)
changelog_embed.add_field(name="🟢",value="/iq",inline=True)
changelog_embed.add_field(name="🟢",value="/say",inline=True)
changelog_embed.add_field(name="🟢",value="/everyone",inline=True)
changelog_embed.add_field(name="🟢",value="/i_love_trains",inline=True)
changelog_embed.add_field(name="🟢",value="/hack",inline=True)
changelog_embed.add_field(name="🟢",value="/eightball",inline=True)
changelog_embed.add_field(name="🟢",value="/bob",inline=True)
changelog_embed.add_field(name="🟢",value="/entwickler",inline=True)
changelog_embed.add_field(name="🟢",value="/userinfo",inline=True)
changelog_embed.add_field(name="🟢",value="/botinfo",inline=True)
changelog_embed.add_field(name="🟢",value="/serverinfo",inline=True)
changelog_embed.add_field(name="🟢",value="/avatar",inline=True)
changelog_embed.add_field(name="🟢",value="/servericon",inline=True)
changelog_embed.add_field(name="Legende:",value="Hinzugefügt:🟢, Entfernt:🔴, Änderungen:🛠️\n",inline=False)```
das wird das größte embed
im gesamtem Bot
muss alle alten Changelog teile einfügen
da ich in v1 alles aus einem Altem Projekt eigefügt hab sind diese natürlich Lang
müssen das wirklich alles eigene felder sein
will das so ja
wäre es nicht besser einfach ein feld zu haben mit newlines
würde genauso aussehen eigentlich
ich find das so ganz gut
na dann
loop.... py for command in [...]: embed.add_field(name="🟢", value="/" + command)
????
ist kürzer
und damit erwischt du auf jeden fall jeden command
und du schreibst nicht 90% das gleiche 20 mal
nennt sich DRY, don't repeat yourself
ok
ääähm kannst du mir Helfen?
Ignoring exception in command ban:
Traceback (most recent call last):
File "C:\Users\leonf\PycharmProjects\Planetbot\cogs\moderation.py", line 63, in ban
await ctx.respond(embed=ban_message_server)
File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\interactions.py", line 585, in respond
return await self.response.send_message(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\interactions.py", line 918, in send_message
await self._locked_response(
File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\interactions.py", line 1243, in _locked_response
await coro
File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\webhook\async_.py", line 220, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction```
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\commands\core.py", line 131, in wrapped
ret = await coro(arg)
^^^^^^^^^^^^^^^
File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\commands\core.py", line 1009, in _invoke
await self.callback(self.cog, ctx, **kwargs)
File "C:\Users\leonf\PycharmProjects\Planetbot\cogs\moderation.py", line 65, in ban
await ctx.respond(f"Es gab ein Problem beim Bannen von {member.mention}.")
File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\interactions.py", line 585, in respond
return await self.response.send_message(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\interactions.py", line 918, in send_message
await self._locked_response(
File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\interactions.py", line 1243, in _locked_response
await coro
File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\webhook\async_.py", line 220, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\bot.py", line 1130, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\commands\core.py", line 376, in invoke
await injected(ctx)
File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\commands\core.py", line 139, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction```
mein Ban Befehl wirft Fehler
@slash_command(name="unban",description="Entbannt einen User")
async def unban(self,ctx,member: discord.Member,*,reason="Keine Begründung angegeben"):#
if not ctx.guild.me.guild_permissions.ban_members:
await ctx.respond("Du hast keine Rechte dafür")
return
if reason : reason
if member == ctx.author:
ban_error = discord.Embed(title="Fehler",
description="Du Bist doch nicht Gebannt wenn du hier Schreibst Witzbold!!!",
color=discord.Colour.dark_red())
await ctx.respond(embed=ban_error)
else:
await member.unban(reason=reason)
unban_message = discord.Embed(title="User Entbannt", color=discord.Colour.dark_red())
unban_message.add_field(name="Moderator", value=f"{ctx.author}")
unban_message.add_field(name="Entbangrund:", value=f"{reason}")
await ctx.respond```
was
wie bekommst du überhaupt ein member wenn der user nicht mehr im server ist
außerdem ist dein error im ban command so weit ich das sehe
und du hast den unban geschickt
ich hole mir da halt die begründung
nee nur ban
also ich weiß nicht aber
unban hab ich noch nicht getestet
das sieht mir nicht nach ban aus
häh schau mal weiter unten
direkt unterm unban befehl
??
ach
du musst schon den ban command schicken nh
außerdem macht if reason : reason absolut gar nichts wenn ich nicht ganz dumm bin
äääh und bei unban nutze ich die user id
sollte ja eigendlich gehen oder?
@slash_command(name="ban", description="Bant einen User vom Server")
@commands.has_permissions(ban_members=True)
async def ban(self, ctx, member: discord.Member, *, reason="Keine Begründung Angegeben"):
if not ctx.guild.me.guild_permissions.ban_members:
await ctx.respond("Ich habe keine Berechtigung, Mitglieder zu bannen.")
return
if member == ctx.author:
ban_error = discord.Embed(title="Fehler",
description="Du kannst dich nicht Selbst vom Server Bannen was hast du überhaupt davon?",
color=discord.Colour.dark_red())
await ctx.respond(embed=ban_error)
return
if ctx.guild.me.top_role <= member.top_role:
await ctx.respond("Ich kann kein Mitglied bannen, das eine höhere oder gleiche Rolle als ich hat.")
return
try:
ban_message_user = discord.Embed(title="Du wurdest Gebannt", color=discord.Colour.dark_red())
ban_message_user.add_field(name="Moderator", value=f"{ctx.author}")
ban_message_user.add_field(name="Bangrund:", value=f"{reason}")
await member.send(embed=ban_message_user)
except:
await ctx.respond(f"Ich kann {member.mention} keine private Nachricht senden, kann aber trotzdem bannen.")
try:
await member.ban(reason=reason)
ban_message_server = discord.Embed(title="User Gebannt", color=discord.Colour.dark_red())
ban_message_server.add_field(name="Name:", value=f"{member}")
ban_message_server.add_field(name="ID:", value=f"{member.id}")
ban_message_server.add_field(name="Bangrund:", value=f"{reason}")
ban_message_server.add_field(name="Moderator", value=f"{ctx.author}")
await ctx.respond(embed=ban_message_server)
except:
```
damit hol ich mir nur den Bangrund
mag sein, dein optiontype ist aber discord.Member, und mit einem userobjekt kannst du kein member.unban aufrufen
da kümmer ich mich Später drumm
reason hast du doch als parameter übergeben? wozu diese zeile
erst ban Befehl
habs entfernt ist auch quatsch
du kannst btw einfach return ctx.respond()
schonmal getestet welche zeile davon den fehler verursacht, bzw, welche zeile davon ist die 63
await ctx.respond(embed=ban_message_server)```
die ist hier aber nicht drin?
doch
wo? 😂
du hast nicht den ganzen command geschickt, außer dein ban command bannt nicht
außerdem ist das unnötig wenn du eh schon den permissions check drinhast
du brauchst btw kein , *, bei slash commands
:>
versuch mal await ctx.defer() als erste zeile, könnte sein, dass du über 3s brauchst zum antworten wenn du so weit kommst
das ist noch vom altem code
ja es finden sich immer wieder alte übereste
achso ne musst du nicht
ah ok
also der ban wird durchgeführt
und der User kriegt ne naricht
per pn
nur ich kriege keinen output
also application did not respond im chat?
dauert das so ~3s bis zur Antwort?
ban_message_server = discord.Embed(title="User Gebannt", color=discord.Colour.dark_red())
ban_message_server.add_field(name="Name:", value=f"{member}")
ban_message_server.add_field(name="ID:", value=f"{member.id}")
ban_message_server.add_field(name="Bangrund:", value=f"{reason}")
ban_message_server.add_field(name="Moderator", value=f"{ctx.author}")
await member.ban(reason=reason)
await ctx.respond(embed=ban_message_server)```
könnte es daran liegen das ich member.ban nach da unten gesezt hab?
neee
das ist grade voll Verwirrend
würde Sinn machen
ja?
man hat max 3s um zu antworten außer man benutzt defer
erste Zeile
wenn's damit sicher geht
es ist halt sau komisch das es Plötzlich geht
bin echt verwirt darüber und weiß nicht mal wie ich das hingekriegt hab
wie setze ich den Unban am besten um?
mit discord.User, und dann ctx.guild.unban(user,...)
@slash_command(name="unban",description="Entbannt einen User")
async def unban(self,ctx,member: discord.User,reason="Keine Begründung angegeben"):#
if not ctx.guild.me.guild_permissions.ban_members:
await ctx.respond("Du hast keine Rechte dafür")
return
if member == ctx.author:
ban_error = discord.Embed(title="Fehler",
description="Du Bist doch nicht Gebannt wenn du hier Schreibst Witzbold!!!",
color=discord.Colour.dark_red())
await ctx.respond(embed=ban_error)
else:
await ctx.guild.unban(member,reason=reason)
unban_message = discord.Embed(title="User Entbannt", color=discord.Colour.dark_red())
unban_message.add_field(name="Moderator", value=f"{ctx.author}")
unban_message.add_field(name="Entbangrund:", value=f"{reason}")
unban_message.add_field(name="User:",value=member)
await ctx.respond```
Ignoring exception in command unban:
Traceback (most recent call last):
File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\commands\core.py", line 131, in wrapped
ret = await coro(arg)
^^^^^^^^^^^^^^^
File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\commands\core.py", line 1009, in _invoke
await self.callback(self.cog, ctx, **kwargs)
File "C:\Users\leonf\PycharmProjects\Planetbot\cogs\moderation.py", line 27, in unban
await ctx.respond
TypeError: object method can't be used in 'await' expression
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\bot.py", line 1130, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\commands\core.py", line 376, in invoke
await injected(ctx)
File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\commands\core.py", line 139, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: object method can't be used in 'await' expression
schick bitte ein mal deinen ganzen code lol, da fehlt doch schon wieder was
häääääh
warum kopiert der das so dämlich
ups
vieleicht sollte ich text ausgeben hahahaha
aber unban klappt
ich sehe es ja im audit log
wie kann ich paginator im select menü nutzen?
name = localizations.get("name")
if name is not None:
if locale == default_locale:
command.name = name
pass
if command.name_localizations is discord.MISSING:
command.name_localizations = {locale: name}
else:
command.name_localizations[locale] = name
why the command.name, complelty fuck the command.name_localizations ?
is there a way to use name_localization but if for example i havent put the german translation or else, it put another one that i choose per default ?
I think the default is just the standard name
nope because when i pass a standard name, the localization stop working
Yea because it probably is None then
this is not meant to happen
im still really confused on your entire bot regarding languages and translation
basically they're trying VERY hard to make it user customizable *via bot commands*, while discord doesn't really account for that
this is before
this is an event that occure after the loading of the cog but before the loading of the bot
and when i add the command.name = the localization stop working
yes
have you considered using a json with the i18n extension
idk why its just the command.name = name that messed up
im kinda doing the same thing
i have 3 yaml
with the translation for each one
french, english
and i wanna have some default for german for example for it swtich to english
with that code :
def localize_command(self, command: discord.ApplicationCommand | discord.SlashCommandGroup, locale: str, localizations: dict):
if isinstance(command, discord.SlashCommandGroup):
for cmd in command.walk_commands():
self.localize_command(cmd, locale, localizations.get(cmd.name, {}))
name = localizations.get("name")
if name is not None:
if locale == default_locale:
command.name = name
if command.name_localizations is discord.MISSING:
command.name_localizations = {locale: name}
else:
command.name_localizations[locale] = name
while with that code :
with that code :
def localize_command(self, command: discord.ApplicationCommand | discord.SlashCommandGroup, locale: str, localizations: dict):
if isinstance(command, discord.SlashCommandGroup):
for cmd in command.walk_commands():
self.localize_command(cmd, locale, localizations.get(cmd.name, {}))
name = localizations.get("name")
if name is not None:
if locale == default_locale:
#command.name = name
pass
if command.name_localizations is discord.MISSING:
command.name_localizations = {locale: name}
else:
command.name_localizations[locale] = name
so that pretty strange, its like editing the name of a command remove the localized from it
doesnt discord's own command localisation completely handle this??
in this instance, where did you set command.name
i didnt set it, and when its not set, the localization work
what happens when you switch your client lang to french then
it still is in french
genuine question btw, not meant to offend
i mean on the 2nd example
for what i wanna do, adding for each single command, each single thing is a lot
(they are using built-in localizations, in this case)
i will do it rn wait
with the french client
but why do it manually? just pass localisations for each command name / option
i genuinely do not understand why you're trying to do it manually
right, so it's working; your FIRST example is broken, not the 2nd
this one is less manual
they're loading from a yaml file and applying TLs through that
im thinking by default it put the french
because its the first one to be load
def localize_commands(self):
self.setup_lang()
languages_data = {
"fr": self.french_data,
"en-US": self.english_data,
"en-GB": self.english_data
}
for locale, localizations in languages_data.items():
for cmd_name, cmd_localizations in localizations.items():
if cmd := discord.utils.get(self.bot._pending_application_commands, qualified_name=cmd_name):
self.localize_command(cmd, locale, cmd_localizations) ```
ok i dont think i understand lol
good luck though, ill be out
yes if for each i need to add the localization
it mean time 400 commandes i will need to add 3/4 translations
and if i add one translation i will have to edit 400 commandes
400 commands
bro's building THE bot
how many sub commands do you got?
or i do something like that who will automatically do everything for me each time
idk i still didnt build my bot in / for the moment
then do that in your command decorator
but my prefix bot has around 300
but can't you just pass a variable / file (loaded to be a dict) to the name_localisations parameter? then you only need to edit the file with your translations like you already have (?)
cos normally it will localizad command before sync it
then it should add the name and also add localization
isnt that basically what you're trying to do with your translator thingy
they wrote their own implementation using yaml, not json
this work but with only 1 language so not multiple
the yaml is read as a json
so its basically a json
well json would work with multiple if you want
like without the command.name = name the localization works perfectly fine
huh?
it'll be
languagecode: name_in_language
and so on
you can have every language you want
maybe i didnt understand what u mean
already saw that and 100 thounsand others
could you perhaps show a sample of your own json, including sub/group commands
yes
i mean you can just have your main translation file in whatever format with all the translations
and then for the name_localisations parameter you put a function that is like get_translation("commandname") and that function returns a dict of the format pycord wants, for that exact command, with all languages you have
or is that not possible
so this :
def localize_command(self, command: discord.ApplicationCommand | discord.SlashCommandGroup, locale: str, localizations: dict):
if isinstance(command, discord.SlashCommandGroup):
for cmd in command.walk_commands():
self.localize_command(cmd, locale, localizations.get(cmd.name, {}))
print(localization)
name = localizations.get("name")
if name is not None:
if locale == default_locale:
command.name = name
if command.name_localizations is discord.MISSING:
command.name_localizations = {locale: name}
else:
command.name_localizations[locale] = name
will give :
{'name': 'mode', 'description': "Active ou désactive le système d'expérience.", 'options': {'mode': {'name': 'mode', 'description': "Sélectionnez pour activer ou désactiver le système d'expérience."}}, 'success': "Le système d'expérience est désormais {mode}."}
for example
what does it look like for your test_english subcommand?
Nelo am i missing something or wouldn't this be easier
well, you could but then you're doing it in every decorator
this is when i remove the command.name = name
yea, but only once
you dont ever touch that again
so it work
yeah but being just "once" doesn't matter
i will print it wait
test_english
{'name': 'test_english', 'description': 'Test command in english.', 'embed': {'title': 'Test', 'description': 'This is a test of the command in english.'}, 'options': {'kind': {'name': 'kind', 'description': 'Sélectionnez le kind de ressource to add.'}}}
i think i might have an idea why now
when it edit the name, when then it try to get the command by the name it not longer the name test by default but test_english and it cannot find test_english as key since its a value
i will keep looking at that to check
yeap excatly it was that, i solved it by creating a function after that put all the default value
however i will have a suggestion
@subcommand(f"{translator.bot.name}")
@commands.slash_command()
@discord.option(parameter_name="kind", name=translator.bot.test.options.kind.name, choices=["xp", "level"], required=True)
async def test(self, ctx: discord.ApplicationContext, kind: str):
translator = get_translator(ctx)
embed = discord.Embed(title=translator.bot.test.embed.title, description=translator.bot.test.embed.description)
await add_embed(embed)
await ctx.respond(embed=embed)
so when a parameter name is adding, make the name optional, because it mean that i will still need to put the name= even if its add like for the slash_command after
like make the name default value parameter name ;)
because for the moment it mean that i have to do that :
@discord.option(parameter_name="kind", name="kind", choices=["xp", "level"], required=True)
to then have that :
however, thanks you @errant trout and @sage tendon for your help at this really late time. I appreciate !
allgood
not name for the option
it is
i got an error if i dont pass it wait
oh you're using decorator i see
2024-04-13 22:11:52 [WARNING] : Failed to load extension Slashs.Bot.test: Extension 'Slashs.Bot.test' raised an error: TypeError: option() missing 1 required positional argument: 'name'
i shouldnt ?
it's fine, it wouldn't change much anyway
so it something who will change in the pycord or i need to continue to do
@discord.option(parameter_name="kind", name="kind", choices=["xp", "level"], required=True)
parameter name is unneeded
If you want to have a different name for the ui and the other it is
No it will not stay like that
It’s edit like for the name and description
In the other part of the code
Maybe since it’s edit in another part it will work without
name localisations dont change the name parameter which dictates with parameter in the function it binds to
if you use the localisations parameter
why
for if for example the user has a german client
and i dont have german translation
it will put by default something
your solution to this is so messy
just use the localisations parameter, dont change the actual option name
wont that change it for literally every server?
that excatly what i just did now
it's likely we won't change the behavior because your method is very much outside the norm
@subcommand(f"{translator.bot.name}")
@commands.slash_command()
@discord.option(name="kind", choices=["xp", "level"], required=True)
async def test(self, ctx: discord.ApplicationContext, kind: str):
translator = get_translator(ctx)
embed = discord.Embed(title=translator.bot.test.embed.title, description=translator.bot.test.embed.description)
await add_embed(embed)
await ctx.respond(embed=embed)
since now i use something outside it work
if you wish to make your own modifications to the library files, you're free to do so
but before it was giving me an issue because i was editing
no like that it work perfectly fine
i dont need the name parameter
even if i edit the name of the option if its in another part than the decorator it work
what is messy ?
it look like that now
and this inclue also automatic translation to english and french using name_localization, and if its from another. like german, since it also edit the command.name etc it will put by default english
wildly points everywhere
but like here what is messy ?
nah i give up i finna completely quit at trying to understand your way, i legitimately do not understand it lmfao
its like now i can code every command without having to put name, description or just think about the localization cos it will automatically do
thats why i do like that
which you could also achieve by simply calling a function for the localisation parameter that gets the right dict for the option in question
you mean by doing that :
@bot.slash_command(
name="ping",
name_localizations={
"en-GB": "British_Ping"
},
description="Ping the bot",
description_localizations={
"en-GB": "British ping the bot"
},
?
yes but that mean i need for each command each description and each option to do that
i guess the point is that through iteration you can do that in a few lines, which is what the i18n extension and luma's method try to achieve
I mean, if you want to localise your entire bot, thats what you gotta do no matter your approach to passing it to pycord
you need to localise everything
lol
that is not gonna work
yea i get it but their current way just hurts my brain
(that's the official example)
that from the doc
🤨
i think that similar to the i18n extension
but im trying to improve myself and so use the less lib that i can
I know and the issue is that name_localizations has to use lower case and it starts with a B instead of a b
yeah what you're doing is fairly similar, i suppose with your own variation
but why not just use that then
since when are command names limited to lowercase
always have been (slash)
oh wait i misread
ok yeah the command name in that example should be lowercase
oh
guess i never thought about that then
@subcommand(f"{translator.xp.name} {translator.xp.setup.name}")
@commands.slash_command()
@discord.option(name="kind", choices=["add", "remove", "edit"], required=True)
@discord.option(name="channel", type=discord.TextChannel, required=True)
@discord.option(name="rate", type=float, default=1.0, required=False)
async def channel_rate(self, ctx: discord.ApplicationContext, kind: str, channel: discord.TextChannel, rate: float):
this will be like that ?
@subcommand(f"{translator.xp.name} {translator.xp.setup.name}")
@commands.slash_command(name_localizations=get_localization("channel_rate"), description_localization=get_localization("commandname"))
@discord.option(name_localizations=get_localization("kind", choices=["add", "remove", "edit"], required=True)
@discord.option(name="channel", type=discord.TextChannel, required=True)
@discord.option(name="rate", type=float, default=1.0, required=False)
async def channel_rate(self, ctx: discord.ApplicationContext, kind: str, channel: discord.TextChannel, rate: float):
command name has to be lower case ;3
nah forgot i didnt understand anything
its also client side @fresh sierra so you cannot create a custome one
yea thats what i meant
wdym by custom one ?
we've already gone through the whole client/bot tl stuff
alright ;3
and dw i finally did it, with that the name, description, option are localized in french/english etc and the response also
we're going in a very big, very confusing circle
nice
so the bottom one is what you do now? or what
no i do the top one
the bottom one was a try to understand what you were meaning
Hi
@bot.slash_command(name='war_plan', description='Generate the war plan for current war')
async def warplan(ctx):
from game import war_plan
from helpers import generate_war_plan_embed
await ctx.defer()
is_plan_generated, plan_response = await war_plan()
if is_plan_generated:
embed = await generate_war_plan_embed(embed=discord.Embed(), plan=plan_response)
await ctx.respond('', embed=embed)
else:
await ctx.respond(f"Please add {', '.join(plan_response)} to the sheet", ephemeral=True)```
How can i send an ephemeral message in case plan is not generated?
defer ephemerally
but then you need to not respond, but ctx.send to respond non-ephemerally
so do just say await ctx.defer(ephemeral=True)?
ctx.send ?
yes
yes
okay I remembered incorrectly, I thought ctx.send was a shortcut for ctx.channel.send
then you have to use that
hmmm seems like, it creates a small issue
the original command does not get a response so its still waiting for one
Hey quick question how to attach a video prview next to a message?
I know if you send links to direct video it will directly show the video through discord (and for sure proxy it)
I was wondering how to do that with pycord
yea you have to respond to that, just say like "sent" or something
okay makes sense
Just send a link lol
what if i say emphemeral=False in the response?
add the video as a file to the message?
doesn't work
not a file since it is too heavy
links get previewed but the link also has to be in the message to be previewed
was wondering if there was a parameter to specify so it gets previewed but withuot having to be sent as a message
A video about neural networks, function approximation, machine learning, and mathematical building blocks. Dennis Nedry did nothing wrong. This is a submission for #SoME3
My Links
Patreon: https://www.patreon.com/emergentgarden
Discord: https://discord.gg/ZsrAAByEnr
Links and Content:
On Mathematical Maturity, Thomas Garrity: https://www.youtu...
for example here
okay and how long after do the emphemeral msgs disappear by themselves?
it sent the info about the video, but im wondering on how to send the info without having the link appear
my closest result is this
[-](https://www.youtube.com/watch?v=TkwXa7Cvfr8)
or with invisible char
discord restart
doesnt work nvm
oh so they dont go away by themselves after fixed interval of time?
not sure you can do that, I think the YouTube and twitter video player embeds are specifically for those websites and only appear with a link
p sure no
yeah there is a special request that goes to the website and returns what they ahve to preview, in my case its just a video on the website, so by sending the link it previews the video
thanks for helping
you could try one thing
specify the embed type as video and then pass the URL via the URL parameter
hmm would this embed the video directly into the embed?
no idea
i dont think thats possible
read somewhere that only images and gifs are allowed
I am playing around with a discord.py bot, I have pretty much everything working that I need (at this time), but I can't for the life of me figure out how to embed a YouTube video using Embed().
I...
oh
so 
lemme try that!
oh I just read discord considers embed types deprecated and the embed attributes implicitly dictate the type now lmao
well if passing the video as a URL doesn't embed it then, then I don't know
well I just checked the pycord docs on Embed
you cannot embed videos
only websites are able to, which is why video embeds exist
I tried setting embed.video attribute and got an error
you might wanna read nelo's messages again
Does Pycord have a native way to check the session start limit?
What is the session start limit
wie kann ich paginator im select menü nutzen?
there is nothing about that in the doc so i guess no, you will have to do a request
Weird.
???
im sorry i dont speak german
but if your question is how to add paganitor is a select menu, paginator has an attribute custom view where you can pass ur select menu
This module provides an easy pagination system with buttons, page groups, and custom view support. Example usage in a cog: API Reference: Page: Attributes content, custom_view, embeds, files. Metho...
Hey there, i just got back to my bot and im trying to register a new slash command group although even if i reload discord it doesn't want to show up.
why do you have an empty line between the decorators
that might be it
also, just fyi, in the command, you never respond to the actual interaction
Yeah just saw it
It didn't fix my problem
hardcode your test server's ID in the guild_ids parameter to make sure it doesnt register in the wrong / no server
Unfortunately it didn't fix it
make sure to restart discord
I just got back to pycord and im really confused im pretty sure im making some stupid mistake
Yeah i tried but it still doesn't show up
try just make it a regular slash command first to see if it shows up at all
also why is literally every string a variable lmao
As normal slash command it shows up
it shouldnt show ctx as parameter though..
i created the slash comand in the main file and i forgot to remove the self parameter
Like this right? https://paste.pythondiscord.com/NK7Q
yea
The problem is the cog then
are you loading the cog in your main file?
omfg, im sorry..
i forgot to load the extension
thanks, where i can find an example of modal?
the docs / guide
we don't, that data is seemingly discarded when connecting to the gateway. That being said, you could view it manually py from discord.http import Route print(await bot._connection.http.request(Route("GET", "/gateway/bot")))
I'm already just making the request, just figured that there should be a built-in way but apparently not. I don't mind, it makes sense since dpy wasn't made for bots who have to worry about this. :p
yeah i guess we never bothered because that's for clustering
we do have the types, they're just never used
could probably include it for completion
Does someone have a hint about paginator having a diferent select dropdown for each page
you can give pages a custom_view
häh
nur immer "häh" zu sagen bringt uns beiden wenig
ich verstehe net wie man das nuzt
probier es aus
hääääh
das ist komisch
@discord.ui.select(
placeholder="Wähle den Changelog", # the placeholder text that will be displayed if nothing is selected
min_values=1, # the minimum number of values that must be selected by the users
max_values=1, # the maximum number of values that can be selected by the users
options=[ # the list of options from which users can choose, a required field
discord.SelectOption(
label="Startseite",
description="Hauptseite des Menüs"
),
discord.SelectOption(
label="1.0.0",
description=""
),
discord.SelectOption(
label="2.0.0",
description=""
)
]
)
async def select_callback(self, select, interaction): # the function called when the user is done selecting options
if select.values[0] == "Startseite":
await interaction.edit(embed=help_embed_default)
elif select.values[0] == "1.0.0":
await interaction.edit(embed=help_allgemein_embed)
elif select.values[0] == "2.0.0":
pages = [
Page(embeds=[changelog_embed])
]
paginator = Paginator(pages=pages, author_check=True, disable_on_timeout=True, show_disabled=False,
timeout=100)
page = await paginator.respond(interaction)
await interaction.edit(page)```
sag mir nicht du benutzt dafür chatgpt
nee
ich komme net weiter
ich meine du machst es einfach nicht lol
einfach custom_view= bei der page
und was muss ich dann angeben?
custom=view=page?
dein view.
custom id?
custom_view=View()
vom Select Menü oder was?
class Changelog_View(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
@discord.ui.select(
placeholder="Wähle den Changelog",
min_values=1,
max_values=1,
custom_id="changelog",
options=[
discord.SelectOption(
label="Startseite",
description="Hauptseite des Menüs"
),
discord.SelectOption(
label="1.0.0",
description=""
),
discord.SelectOption(
label="2.0.0",
description=""
)
]
)
async def select_callback(self, select, interaction):
if select.values[0] == "Startseite":
await interaction.edit(embed=help_embed_default)
elif select.values[0] == "1.0.0":
await interaction.edit(embed=help_allgemein_embed)
elif select.values[0] == "2.0.0":
pages = [
Page(embeds=[changelog_embed])
]
paginator = Paginator(pages=pages, author_check=True, disable_on_timeout=True, show_disabled=False,
timeout=100)
page = await paginator.respond(custom_view=View())
await interaction.edit(page)```
Guck dir die Docs an
?
ctx.interaction geht ja nicht
was?
we aren't SQL support
This support channel is typically relatively lenient but SQL has absolutely nothing to do with pycord
oka
hab das menü extern
ich muss einfach nur verstehen wie
What would be the best way in a modal to check if x text matches something and if not give an error to the user?
I would need to close the modal or i can give an error directly into the modal?
Is there a list of breaking changes from 2.4 to 2.5 somewhere?
its not a major update so there arent any
semver be thanked
tho i think there was one change to some bridge stuff that made the bridge options behave a bit differently, not sure if that was intended tho
is there a specific issue you have
Nah, just wondering if there were any major changes I should know about before updating.
you'd have to send a response with a button to trigger the modal again
do you use bridge commands?
negative, fully slashed out bots only here.
I was typin the answer 😭
then you're safe
👍
skill issue tbh
generally, for minor updates (1.X.0), there are never breaking changes (on purpose)
that's how semantic versioning dictates it
if there's any breaking changes we (are meant to) very clearly announce it
strictly speaking any breaking change would have to wait until 3.0
nah we plan on making some anyway
breach of semantic versioning
oh no! anyway
iirc between 2.2 and 2.3 there were also some 🤷
It's no big deal either way, just wanted to know for sure before I updated, that's all 🙂
i mean i generally do expect any library i use to strictly keep to semantic versioning 
especially so that requirements.txt using ~= work fine
You expect too much from the world
Ty
Mandatory xkcd post when someone mentions standards https://xkcd.com/927/
i mean no one wants to compete with semver tho
pragmatic versioning, calver, wendtver, semver-ish, and calendar versioning are a couple 😛
Yeah but I need to change the select in the view, like the select has 20 options in the first page but 7 on the 2nd (just giving random numbers), how do I get the interaction that happened in the paginator and not in the view, so I can update the view and then update the paginator
each page has a custom_view parameter
so if the next page is selected it also changes the view accordingly afaik
pages have a lot more attributes than that :)
How to access VoiceState.channel for a certain user if Member object doesn't have that attribute
i didnt even know you could make a paginator without that
i mean if that member doesnt have it, then you just cant access it
oh, i misread
lol, i just passed a list of embeds all the time and I did not even think about the Page class 
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 ...
hmm, do y'know where I can propose some change to those docs? because they don't say that Member.voice has attributes that inherits from another class it isn't that obvious
yea i was also wondering why it has no return type shown
but from the words alone i would say it just returns a VoiceState object
I guess it's a programmer's job to find that by trial and error lol
i mean the docs are just better than most i read out there
these are minor things imo, usually the return type is given (and linked)
our docs theme comes with the *minor* inconvenience of not properly typehinting @property
it'll hopefully be fixed at some point, but at the moment this is a general issue
Is there a way to access the ctx.guild's banlist? or just the guild's banlist?
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 ...
as always, docs are your best friend
und das tue ich grade nicht
Hey! I am trying to get a contact me set up. Though I want to initialise myself in the init function of the cog. Though I am running into some issues: see screenshots below. It is not the fact that get_user() is taking a string, giving it an integer gives the same result
doing it on init means it happens before the bot started, so there's no cache
Hmm so I can't init get_user or just not the print?
can't do get_user in init (at least on first load, it would work on subsequent loads)
I guess I'd have to event another on_ready to do it the way I want to?
you can use an on_ready listener, just make sure it doesn't get overridden on subsequent reloads
alternatively, you could make it a @property py self._nico = userid ... @property def nico(self): return self.bot.get_user(self._nico)
cool thanks, I'll read into @property in that case
I am running a ping slash command in a cog, which works fine. When I then create a slash command with the same code inside in a different cog (did change the name of the slash command a bit) it doesn't detect it at all. But when I comment out the first ping command, the 2nd one does work
testing purposes dw
Was tryna find out if it was the code inside the slash command
Wait. Does my way of loading cogs work in pycord? I think it might not 1 sec
Wait that shouldn't be the issue cause when I comment out the "ping" command it works in the other cog
bot.load_extensions("cogs") is shorter
oh didn't know that was a thing. Yeah its my first time using pycord and first time using slash commands in general
so having some issues 
as long as they're loaded before starting the bot
It's just weird the slash command in my first loaded cog stops working when there's a slash command in a later cog
show the entire cogs
import discord
from discord.ext import commands
from decimal import Decimal
class Utilities(commands.Cog):
def __init__(self, bot):
self.bot = bot
@discord.slash_command()
async def ping(self, ctx):
await ctx.respond(f"Pong! {round(Decimal(self.bot.latency*1000),3)}ms")
def setup(bot):
bot.add_cog(Utilities(bot))
oof py fail
import discord
from discord.ext import commands
from decimal import Decimal
class Contact(commands.Cog):
def __init__(self, bot):
self.bot = bot
self._nico = '206447192590909440'
print(self._nico)
@discord.slash_command()
async def whois(self, ctx):
await ctx.respond(f"Pong! {round(Decimal(self.bot.latency*1000),3)}ms")
def setup(bot):
bot.add_cog(Contact(bot))
restart the bot, wait until its started, restart your discord, then check again
best check is if it shows when you go to guild settings > integrations
absolute saviour. Do I have to keep doing this for all of the slash commands I add?
i mean discord is just awful with syncing slash commands in real time
always restart after adding or changing one
does discord have a force restart hotkey?
ctrl+r
cheers
@errant trout After setting @property how do I use that? As the def nico is not callable
Hmmm lovely stuff. Got to love my user id not existing 
import discord
from discord.ext import commands
from var_dump import var_dump
class Contact(commands.Cog):
def __init__(self, bot):
self.bot = bot
self._nico = 206447192590909440
@property
def nico(self):
return self._nico
@discord.slash_command()
async def whois(self, ctx):
print(self.bot.get_user(self.nico))
def setup(bot):
bot.add_cog(Contact(bot))
arent IDs strings
no
same result
welp
what intents do you have
all for testing purposes :)
(also, my intent was that in property you run get_user so you can simply use self.nico wherever)
did you also enable them in the dev portal?
(I am stupid and I don't wish to talk about my mistakes)
definitely not my main.py right after I said I had all intents
line 5 is unnecessary
I know I am tired, deleted it right after the screenshot 
brainstorming here, can a command triggered in DMs to the bot create a channel in my private discord server?
if you want
sure
just use get_guild
cheers, great to have people that know this by heart rather than having to find out if its even possible, myself
so in this case I can once again have a property for the guild and use (example) self.server.create_text_channel()?
mhm
How do I get a category? I need to create the text channel in a certain category but get_category doesn't exist sadly enough
New problem arises
I am trying to find a method that returns all channels in a server (server is defined by an ID)
Well mostly I am trying to find out if a channel with a certain name already exists
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 ...
for channel in ctx.guild.channels:
# code here
I am getting Missing access when trying to register commands, what could be the cause ?
?tag missing_access
If you get a Missing Access (50001) error, you probably forgot to add the applications.commands scope.
To fix that, just re-invite your bot to the guilds you specified guild_ids or debug_guilds for.
I do have it, when I click on the invite links it says it is there
check the IDs again
the guild's IDs
they are None
you specified debug_guilds or guild_ids somewhere in your code and your bot is not in one of those guilds
you could be passing in the wrong bot's token, too
I see I will check that ! Thank you ! Maybe it is the wrong bot token
Still kind of confused here. Why is Option getting depricated within slash context? BridgeOption within slash commands don't seem to make any sense to me. Shouldn't this be the other way around, BridgeOption depricated instead of Option?
thats.. not whats happening
you need to use bridgeoption for bridge commands
which is why that message appears if you import bridge as nelo said
I'm getting this error on some code for the @option decorator for slash commands
Could someone explain to me what it means and how I would go about fixing it?
show your code, the entire command
here
import discord
from discord import Option, option
from discord.ext import commands
from discord.commands import slash_command
import json
with open("contentdata.json","r") as file:
jsonData = json.load(file)
subjectsdata = jsonData["Subjects"]
print(subjectsdata)
subjects = [''.join(subject.keys()) for subject in subjectsdata]
server = 1226452892899217461
admins = [675238101253226496]
print(subjects)
class categorycreation(discord.ui.View):
def __init__(self):
super().__init__()
@discord.ui.button(label="Yes", row=0, style=discord.ButtonStyle.success)
async def accept_button_callback(self, button, interaction):
await interaction.response.send_message(f"The category has now been created", ephemeral=True)
@discord.ui.button(label="Abort", row=0, style=discord.ButtonStyle.danger)
async def deny_button_callback(self, button, interaction):
await interaction.response.send_message(f"You have succesfully aborted the creation of the category", ephemeral=True)```
class contentsub(commands.Cog):
def __init__(self, bot):
self.bot = bot
@staticmethod
def subjectAutocomplete(self: discord.AutocompleteContext):
return subjects
@slash_command(guild_ids=server, name='contentsubmission', description='Send in your resources to gain access to other resources!')
@option(name="subject", description="Your selected subject for this content to be submitted in", autocomplete=subjectAutocomplete)
async def contentsubmission(self, ctx: discord.ApplicationContext, link: Option(description="A google doc link to your content", required = True), subject: Option(description="The respective subject your content belongs in", required = True)):
if subject not in subjects:
embed = discord.Embed(
title="Content Submission",
description=f"Your subject doesn't seem to exist yet. Would you like to create a new category for it?",
color=discord.Colour.from_rgb(255,255,255))
embed.set_author(name='Source', icon_url='https://res.cloudinary.com/drt9lxvky/image/upload/v1712798628/sourcev1.png_uzc8zh.jpg')
await ctx.respond(embed=embed, view=categorycreation(bot=self.bot))
else:
embed = discord.Embed(
title="Content Submission",
description=f"Thanks for submitting the content. Please make the document view only and add the email: to it",
color=discord.Colour.from_rgb(255,255,255))
embed.set_author(name='Source', icon_url='https://res.cloudinary.com/drt9lxvky/image/upload/v1712798628/sourcev1.png_uzc8zh.jpg')
ctx.respond(embed=self.embed)
def setup(bot):
bot.add_cog(contentsub(bot))```
dont mix the decorator and the typehint variant
use either the option decorator or the typehint, not both, that wont work
ah makes sense
right so let's say that I used the decorator for the subject parameter and then the typehint for the link parameter would that be ok?
I just wanted to know if it would work
yea
Mhm, maybe I should put my small command builder online
and also wondering how I would put restrictions on it
like for example for typehinting we could do
member: discord.Member
input_type=
but i usually pass name and type positionally in the decorator
saves space
ah ok
i dunno if i'm blind or something
but is there like a list of the input types
on docs
not sure but there's not really that many
There is not really a list for it
ah ok
im having issues getting my commands to sync
could it be because of rich presence?
bots cant have rich presence lol
why do you redo that every minute
Honestly I'm not sure I just thought it was convention because maybe it would stop if you didn't because I saw someone do it
just do it in your bot definition
You should also wait until ready at tasks
sorry I don't understand how would I go about doing htat
so wait until it's on_ready??
discord.Bot(activity=...)
ah thanks
i'm still getting the same error
and it's preventing my new cmd to be used
well, show the complete error
nevermind
I managed to fix it one of the guildid global variables weren't defined properly as a list it was a int an not iterable
await client.wait_until_ready() at your tasks
I'm guessing pycord does not support discord polls yet?
it's waiting for discord's own PR to merge
How come this still allows @ everyone to be mentioned?
what allowed_mejtion is used for ?
to control what the bot can ping in a message
yes, but my problem currently is that that will still ping everyone
tho i think i know why
yea okay i had to explicitly pass everyone=False too
Hey there, i was creating a command but when i run it i keep getting the same error. It should modify a value in a database.
Code and Error: https://paste.pythondiscord.com/FNXQ
what line even causes that
just blindly judging by the weird error i think its because of your option name sub_name?
try changing that
the command doesn't want to update, tried to force reload ds and restarted but nothing
did you change the name of the option and the function parameter
changed the name of the option, but unfortunately i still get the same error
It might be my code but I found some strange behavior, where autocomplete function retrieves the word the user types twice.
Is this the intended behavior?
It can cause wasted compute if you're not careful
https://discord.com/channels/881207955029110855/1229479667845697637
is it my library thats outated?
well, what version do you have?
also i dont think thats a valid optiontype anyway, but not sure
?tag defer
No tag defer found.
just ask
sorry for late, it's 2.5.0
yea that's the latest version
Are you sure you dont have discord.py installed (as well)?
yea no you cant access BanEntry, i just tried
and really there is no point to ever manually accessing that class
BanEntry can't be an option
await ctx.defer()
embed = discord.Embed(title="Stworzono Ticket", description=
f"""
:IlusionEmotes67: - Użytkownik: {interaction.user.id}
:IlusionEmotes78: - Otwarto ticket: {option_label}
:IlusionEmotes30: - ID Ticketa: {ticket_id}
""", color=0x982afe)
embed.set_thumbnail(url=interaction.user.display_avatar.url)
await ticket_channel.send(f"{interaction.user.mention} ∙ <@&1217917143996432495>")
await ticket_channel.send(embed=embed, view=CloseButton(self.bot))
embed = discord.Embed(description=f"> :IlusionEmotes74: Dziękujemy za utworzenie ticketu! Twój kanał: {ticket_channel.mention}", color=0x982afe)
await interaction.response.send_message(embed=embed, ephemeral=True)
except Exception as e:
print(f"Error creating ticket: {e}")
embed = discord.Embed(description=f"> :IlusionEmotes74: Dziękujemy za utworzenie ticketu! Twój kanał: {ticket_channel.mention}", color=0x982afe)
await interaction.response.send_message(embed=embed, ephemeral=True)
select.callback = select_option```
sometimes i got a error "interaction not found"
idk why
so i want to use "defer"
maybe it will fix the problem
but i don't know how
did you check which line causes that error
might be related
File "/home/container/.local/lib/python3.10/site-packages/discord/ui/view.py", line 426, in _scheduled_task
await item.callback(interaction)
File "/home/container/KategoriaPrivate/Tickety/nowetickety.py", line 193, in select_option
await interaction.response.send_message(embed=embed, ephemeral=True)
File "/home/container/.local/lib/python3.10/site-packages/discord/interactions.py", line 918, in send_message
await self._locked_response(
File "/home/container/.local/lib/python3.10/site-packages/discord/interactions.py", line 1243, in locked_response
await coro
File "/home/container/.local/lib/python3.10/site-packages/discord/webhook/async.py", line 220, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
the thing is, sometimes it works, sometimes it doesn't
are you taking long to respond, like, up to 3 seconds?
oh that's in a view right?
yea views dont work anymore after 15 minutes, that might be why
you need to increase your views timeout. If you want it to always work you can use a persistent view
Here's the persistent example.
how do I create a role after a button click?
I answered in the other thread you were in
would there be a way to then get the role id of this created role
would it be using the get_role method
i've just read the docs
and it says that the create role coroutine returns a "role" object
which has alot of attribute like id
how would I go about accessing it
the function returns it but do I store it as a variable?
myrole = await interaction.guild.create_role(...)
print(myrole.id)
?
is there a way to move channels around in a category? like each channel has a number at the start of it so i wanted to order them from least to greatest
Why channel purge with high limit is so slow?
discord, that's why
yes, check the docs
How often can you edit a message with a persistent view? Had one running for a while but it slowly fell behind on the edits over time.
The message is something along the lines of OPTION is deprecated use BRIDGEOPTION instead.
It doesn't make sense that it appears since I don't use bridge & it doesn't make sense that OPTION is deprecated for slash commands.
I believe this is a little something that Nelo did the wrong way around, or something is not working as intended.
are you importing anything bridge related?
How would I update the bot status like online, idle etc. without removing the current activity? Is that possible or do I have to keep track of the current activity myself and pass that to change_presence too, every time?
is the current presence stored somewhere in the bot?
Any way to establish Cog to Cog communication without going over the bot or am I doomed to do it over the bot?
what do you want to do
Cog A sends something to API of my backend and needs to tell Cog B to update a scoreboard in a channel
just make a function call from one to the other lol
okay, glad you confirmed I was overthinking it
cog a
async def doStuff()
cog b
//commandcode
coga.doStuff()
*do_stuff
I'm on phone don't judge my amazing codeblock
I'm just coming out of a java lecture
not an excuse /j
smh
What got you started?
does anybody know why its not working, no errors
Need to commit
ohhh
but again, this isn't SQL support, there's plenty of documentation for the mysql library
used commit but still deoesnt work
:)
pls 😂
Hi, i am trying to execute pycord bod and a while loop at the same time. I was trying multiple aproches but none of them work, this is my broken code for reference:
Crypt(key=key)
kokot_thread = threading.Thread(target=import_system.kokot())
bot_thread = threading.Thread(target=bot.start())
bot_thread.start()
kokot_thread.start()
bot_thread.join()
kokot_thread.join()```
kokot_thread is just a while loop. In this case, whatever thread runs first will be the one that is working, but never both at the same time
what does the while loop do
just prints stuff and sleeps for 1 second
make it a task then
how? should i use asyncio tasks?
dont use threads at your bot
with asyncio
so i should start the bot normally with bot.start() and place the other stuff into asyncio task?
usually bot.run is the very last statement in your main.py
so you dont really ever need to wrory about it being async aka bot.start, usually you use bot.run
this is bot.start() 😄
am gonna change the token later btw
nice token leak
yeah, theres like nothing on it
tasks are i think @bot.task
look it up on the docs
you can then start that task from e.g. the on_ready to make sure your bot is ready before, well, starting the task
well the bot isnt the main thing, it should run separatly from the other tasks
meaning the start_services function should start bot and some other stuff that does loops
eh
and i noticed that executing it on other thread doesnt work
thats why i came here 😄
i am trying something that executes the bot and some other looping functions like at the same times
that other functions have no problem being executed on another thread
await bot.start :>
await bot.start()
huh? i tried putting async before the function start() too
and it prined this error
the problem is that i cant call the bot.start() on anything else than main thread
you have to use asyncio
like how exactly?
asyncio.run(the function())
you mean for the other function?
not for the bot
i already do that
from what i know, you cant execute async function from a sync funtcion
thats why there needs to be asyncio.run(start_services(key))
but yeah, i can do this too
but the problem is somewhere else
like when calling bot.start() nothing afther will ever execute
and i put my loop function before that
....thats what asyncio.run fixes
it will not get to bot.start
are you ignoring all warnings on purpose?
lol
but thats not gonna fix anything, like the start_services can run synchronously just fine, the problem is to get the things inside that function to basically start at the same time
these 2 functions are supposed to run at the same time, but whichever i put first will be the one that will execute
i tried threading, but that doesnt work with the bot
why do you even have a function for that
just put it at the bottom of your file
because the bot should only run when a decryption key is recived, this file is meant to only obtain that from user and than start certain stuff
but if i do this, the first function starts a loop and the second cant load because it is stuck
what for lol
database
why dont you let the bot just run
because the bot isnt the only thing thats supposed to run
yea i got that by now
i found a way to fix it
how would I go about dm'ing audio recordings to the user who invoked the slash command instead of posting it into the channel where the slash command was invoked?
ctx.member.send
Pops an error
that's not a slash command
well it is but that's just a function you're calling within the command
yea, I'm at a loss on it. Never coded a bot before
just pass ctx.member to that function as member and then member.send
and remove that *args
multiprocessing ....
also why are you typehinting the channel as Textchannel lol
idk lol, I got the code from the pycord site for audio recording
ah probably because they sent it to a channel after
wait you arent calling it the way I expected initially nvm
hm I've never used the recording thing either tbh
I passed ctx.member as member and when I invoke the slash command I get this error
ctx.author, mb
that worked, ty so much
Wie lege ich beim Schreiben eines Create Channel Befehl fest in welcher Kategorie dieser erstellt werden soll
steht alles in den docs
Ich find's net
discord.TextChannel
steht alles da :)
https://docs.pycord.dev/en/stable/api/models.html#discord.Guild.create_text_channel hier meine ich*
aber da solltest du sowieso schon geguckt haben :)
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 ...
Das hab ich gesucht danke
Das ist da auch so erklärt das ich es verstehe super
Hab die allgemeine Suche genuzt
What is the right way of putting more images in the same embed? Just using #set.image() over and over?
und nach discord.TextChannel heducht
ich auch :>
you think it would be that intutive no :)
embedname.set_image(url=url)
non-website embeds can have multiple images?
to add multiple images to a single embed, you need to create multiple embeds
and each embed would have to have the same url and name
and then you can add images to those embeds
does that legit end up being one single embed in chat?
if i described/remembered correctly, yeah
jfc
Well, tbh im a little bit confused but i'll try
you aren't alone on this lmao
#1117988200921702450 message

