#Basic Pycord Help
1 messages · Page 30 of 1
no
and it will only tell you ,ew boost and not unboost
i said that already, and i say this for the second time now
i think there is no way to know who unboost the server if its only 1 out of the 2 boost
It would fire as many times as the event happens.
If someone removes 1 boost, it will fire once.
Removes 2 boosts, fires twice.
etc...
no but like to know who unboosts
cos someone can boost 1, 2, 3, etc times
Well yes, it would be in the message. There's also most likely some kind of boost.author attribute 🤷
You can't tell that, as long as they don't remove all their boosts, or are adding their first boost
for the boost, not the unboost
for the boost you can check message.author
since system message are our message
but unboost u ony have the guild event so it will only say the guild lost. a boost without any more information
That's just how it us unless you want to go make a pr on the Pycord repo
off-topic now :)
whoops...
didnt understand what u mean
Extension 'cogs.ticket' raised an error: TypeError: 'type' object is not subscriptable
what is this error message?
is there more to that error?
yes.
well, show it
please show the full error. you can ofc edit out your account names and such.
nothing error in console, that text displayed in cogs reload command
try:
bot.load_extension(f"cogs.{extension}")
print(f"[LOGS] 명령어로 인해 cogs.{extension}이 로드되었습니다.")
except Exception as e:
embed = discord.Embed(title="❎ Extension 로드 실패", description=f"> `{extension}`을 로드하는 중 오류가 발생했습니다.\n\n`\`\`\n{e}\n\`\`\`").set_footer(text=":seedling: Copyright 2024. Lucy Studio all rights reserved.")
await ctx.reply(embed=embed)
return
embed = discord.Embed(title=":white_check_mark: Extension 로드 성공", description=f"> `{extension}`을 로드했습니다!").set_footer(text=":seedling: Copyright 2024. Lucy Studio all rights reserved.")
await ctx.reply(embed=embed)
(this is part of reload code)
bot.get_user(id)
that gets you the user object, if they're cached
mhm and how can i send them a dm
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 ...
seems like there is a problem with your ticket file. does this file have the needed setup? is it a pythong file? what does your loop before "try" look like?
Just wondering, why do you only have an ID?
I am not good at guessing 😄
def load_all_extensions():
bot.load_extension('jishaku')
print(f"[LOGS] cogs.jishaku가 로드되었습니다.")
for fn in os.listdir("cogs"):
if not fn.startswith("-") and fn.endswith(".py"):
try:
bot.load_extension(f"cogs.{fn[:-3]}")
print(f"[LOGS] cogs.{fn[:-3]}이 로드되었습니다.")
except:
continue
def unload_all_extensions():
bot.unload_extension('jishaku')
print(f"[LOGS] cogs.jishaku가 언로드되었습니다.")
for fn in os.listdir("cogs"):
if not fn.startswith("-") and fn.endswith(".py"):
try:
bot.unload_extension(f"cogs.{fn[:-3]}")
print(f"[LOGS] cogs.{fn[:-3]}이 언로드되었습니다.")
except:
continue
...
@bot.command()
async def sys_load(ctx, extension=None):
if ctx.author.id in [491889531826601984, 1073035390803513414]:
if extension is None:
load_all_extensions()
embed = discord.Embed(title="✅ Extension 로드 성공", description=f"> 모든 extension을 로드했습니다!").set_footer(text="🌱 Copyright 2024. Lucy Studio all rights reserved.")
await ctx.reply(embed=embed)
elif extension == "jishaku":
bot.load_extension('jishaku')
print(f"[LOGS] 명령어로 인해 cogs.jishaku이 로드되었습니다.")
embed = discord.Embed(title="✅ Extension 로드 성공", description=f"> `jishaku`을 로드했습니다!").set_footer(text="🌱 Copyright 2024. Lucy Studio all rights reserved.")
await ctx.reply(embed=embed)
else:
try:
bot.load_extension(f"cogs.{extension}")
print(f"[LOGS] 명령어로 인해 cogs.{extension}이 로드되었습니다.")
except Exception as e:
embed = discord.Embed(title="❎ Extension 로드 실패", description=f"> `{extension}`을 로드하는 중 오류가 발생했습니다.\n\n\n{e}\n").set_footer(text=":seedling: Copyright 2024. Lucy Studio all rights reserved.")
await ctx.reply(embed=embed)
return
embed = discord.Embed(title=":white_check_mark: Extension 로드 성공", description=f"> `{extension}`을 로드했습니다!").set_footer(text=":seedling: Copyright 2024. Lucy Studio all rights reserved.")
await ctx.reply(embed=embed)
this is a load command, ticket file is discord Cog file.
not making massdm dw, uh im integrating an in-discord payment system using sellix api and user id is passed into invoice as a custome field or smth like that and when sellix webhook receives an alert that invoice is completed it DMs the user by ID
what do u think is there an other solution?
only you know that stuff whatever you're doing there
oki 🤷♂️
i couldve made sql db with order-id and user ids but too much effort
bot.load_extension(f"cogs.{extension}") <- your extension variable, passed by the user could be anything, cause you have a wildcard "else".
it will try to load whatever name a user puts in, regardless if it exists within your cog folder.
maybe store the extension names and check if the extension a user tries to load actually exists. also if the extension is already loaded.
if the input refers to a none existent extension or the extension is already loaded it'll run into an error.
It definitely exists. that command only used by me
maybe you tried to load a single extension that was already loaded by this load all extensions thing then?
that not. i used reload command, that returned this extension is not loaded
do you happen to know how many members or servers are cached in what time when you start a bot?
was it 2 per sec?
isnt it instant as soon as on_ready is called?
like its done once on_ready is called?
yes, i am trying to calculate how long it'll take to get to the on ready event after starting up the bot
alright
it probably scales linearly with guild and member counts
As per https://discord.com/developers/docs/topics/gateway-events#request-guild-members, on startup the bot will request at most 1k members per guild per request
hope i get them all in cache.
I do have both, presence and guild members intend.
Do i need to change anything in my code to make the bot load all members?
No, it does it by default
alright, that's good. very good. still trying to figure out an time estimate though. last time i checked it was like 1.4 million people the bot monitored. how often/fast does one get one of those "1k chunks"
Well
That's minimum 1400 requests
Probably a few mins? Idk
Try timing it yourself
probably half an hour lol
I mean for me, 50k members is like a few seconds so I'm just guessing from that
Do you know how can I make a prevname system interbot in pycord using 1 single database. For in every bot I can go through the database without having to connect with each bot
Idk if it’s clear
hello, sometimes i got a error with the button "interaction not found" sometimes it works sometime not, what's the problem?
do you take more than 3s to respond?
Do you use defer ?
How to update bot user banner via code?
Not possible yet
But it will be with
bot.edit(banner=
But when?
You can use the dev version but it’s unstable
Or wait for pycord 2.6 I guess
do i need that?
when i use that it would fix my problem?
Depend if ur interaction take more than 3s to execute
With defer you can wait for 15m before responding
and we are back to my initial question which remained unanswered
I hope pycord 2.6 will be released in this year)
Yep it will
When using py-cord with AutoShardedClient / AutoShardedBot i get this error every few hours, i could not supress it in the on_application_error event so it crashes all the time
0|pepperai | File "/usr/local/lib/python3.8/dist-packages/discord/shard.py", line 475, in connect
0|pepperai | raise item.error
0|pepperai | File "/usr/local/lib/python3.8/dist-packages/discord/shard.py", line 180, in worker
0|pepperai | await self.ws.poll_event()
0|pepperai | File "/usr/local/lib/python3.8/dist-packages/discord/gateway.py", line 605, in poll_event
0|pepperai | await self.received_message(msg.data)
0|pepperai | File "/usr/local/lib/python3.8/dist-packages/discord/gateway.py", line 555, in received_message
0|pepperai | func(data)
0|pepperai | File "/usr/local/lib/python3.8/dist-packages/discord/state.py", line 818, in parse_interaction_create
0|pepperai | interaction = Interaction(data=data, state=self)
0|pepperai | File "/usr/local/lib/python3.8/dist-packages/discord/interactions.py", line 171, in __init__
0|pepperai | self._from_data(data)
0|pepperai | File "/usr/local/lib/python3.8/dist-packages/discord/interactions.py", line 201, in _from_data
0|pepperai | self._guild = Guild(data=self._guild_data, state=self)
0|pepperai | NameError: name 'Guild' is not defined
i used python 3.8, 3.11 and 3.12 but all got the same error
it's from within py-cord
bridge, right?
What do you mean?
you are using bridge commands right?
No i use the bot.command()
hm
yea not sure, i know that error is usually related to bridge commands, but if you dont use them, then i dont know
seems like a typo in py-cord
somewhere in the sharding
only using discord.AutoShardedBot will give the error
without any commands also
it happens every few hours
hm
This is fixed on master
why cant there be a 2.5.1 with just that fix
Is it recent because i also tried the latest pypi version
the repo is ahead of 2.5
Yes, not pypi
I think i got it, i will let it know if the error occurs again
if you use discord.Guild as an option type, how does that match by name? 2 servers can have the same name
they are different guild objects though, right?
yea duh
but you can enter server names in a discord.Guild option
and with testing i found out that it seems to always "match" the one the bot joined first
dont quote me on that though
Ohhhhhh! you mean it is used as an input option for the end user!! 😮
Like it will actually resolve into a guild object for some ungodly reason
i never knew this was even possible
yea, admin only cmd
and somehow a guild name perfectly resolves into A guild object
but you can never be sure which one if 2 servers are called the same :>
Yeah, I got it. just.. why have this option in the first place? what's its supposed purpose?
blacklisting.. I see.
well, using the id will solve it.
true but it's such odd behaviour, I never expected that to work
Is there a way to a paginator edit its own message instead of responding the interaction?
i think the method "update" solves this
brb
discord.Guild is a fake option type
it goes in the order of bot.guilds
we support several fake option types with converters internally
you can also get discord.User when you use .Member as an option.
Easy to reproduce:
On the user side insert a valid member for the slash command, kick them member, go back to the command and hit enter.
Took me a while to figure this nonsense out 😄
got a note worthy one to tell about in mind?
not in particular
in theory, any Converter is supported
also enums automatically expand into choices
How do I add text and media within modals? if there is part of the documentation that answers this, just send that please
you can't lol
rip, is there another way to show a popup?
yeah it's called a website
I just want to know If I can add any text or extra guiding elements into a model, I know you can do this with just an embed, but just wondering If I could do it within the window
nope, you can't
Is it possible to forcibly unregister slash commands global commands on bot.close()? I have already overwritten the bot.close() function so i just need to handle the unregister in the overriden close()
use bot.sync_commands with an empty list
How to install wavelink without discord.py?
Install the github version
Wavelink is not supported by pycord 2.5
pip install ... --no-deps
If my bot is AutoShardedBot, should i also typehint it like that in cogs?
or is discord.Bot "close enough"
you can type-hint it discord.Client because that's "close enough"
no but seriously
should i typehint it as autoshardedbot or is there no real difference
discord.Client is just weird to me
the difference is the shard methods/attrs
yea
it's completely correct tho
yea ig
why would you typehint bot as client when the only point of typehinting in python is to satisfy your IDE for autocomplete
like sure it's "correct" but then you're blatantly missing methods
Is it possible to "lock" an input field modal so a user cannot type in it
Hi there!
Small question, I'm doing an command with autocomplete, I return a list of roles. How can I display them? If I put discord.Role it shows me those of the server and not the returned list.
role: discord.Option(discord.Role, "The role to remove the points.", required=True, autocomplete=get_role_points)
no
you would have to remove it
no, buy 16€ valorant avatar decorations
real


Yup, you just found out why autocomplete sucks
autocomplete can only do text and numbers
that is not how it works
Do you know of a better solution or am I going to have no more interesting option than a string?
?
well, you can use the role names as the autocomple options for the UI, and then as their value, you put the role IDs
Ugly and hacky, but works
Then in the command you just get / fetch the role by ID
That's what I was already doing, I had hoped that good old discord had come up with something more interesting...
Well
You can also just make a plain old role selector and then check if the role is valid or not in the command
Yes, I'm going to do that, no choice anyway...
Thank you for validating my doubts.
@discord.slash_command(guild_ids=[MAIN_SERVER], description="Komenda do usuwania wyznań z sekcji-nocnej.")
async def delete(self,
ctx: discord.ApplicationContext,
numer: Option(
int, "Numer wyznania które chcesz usunąć.",
)):
channel = ctx.guild.get_channel("1219962947267203174")
message = await channel.fetch_message("1227668643924414486")
new_content = "Updated content goes here"
await message.edit(content=new_content)
Why this doesn't work? Trying to fetch a message and edit it inside a cog class
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'NoneType' object has no attribute 'fetch_message'
because that channel is None
either because it's not cached or it doesn't exist
Do a None check on channel, and if it is none, use fetch_channel instead
discord.Role already shows all the roles at the server
they want a specific set of roles
Can you combine option types with e.g. discord.Member | discord.Role and it'll show both in an option?
no, but you can specify SlashCommandOptionType.mentionable (forgot the exact name) for member, role and channel
you can do it with typing
import typing
typing.Union[discord.TextChannel, discord.Member]
@sage tendon
cant u do choice=[discord.Role, discord.textchannel] ?
no
you have to do it like that
remove the "", get_channel is take an int not an str so channel = ctx.guild.get_channel(1219962947267203174)
oh... right lol
this does not work
try it ;3
i thought type | type2 was a union?
invalid usage of typing.union
that's the new style yes
union works for prefix but it has no effect on discord's option display
it was possible....
Why tf channel.slash_commands(command_ids=[id]) doesn't return anything for command ID which still exists, while nothing else on the code changed? is this discord api misbehaving again? what can I do?
from typing import List
from discord.ext import commands
import discord
from discord import slash_command
from discord import ui
class MyView(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
@discord.ui.select(
placeholder="Welche Kategorie möchtest du sehen?",
min_values=1,
max_values=1,
custom_id="select_help",
options=[
discord.SelectOption(
label="Allgemein",
description="Allgemeine Befehle",
value="1"
),
discord.SelectOption(
label="Spaßbefehle",
description="Befehle nur zum Spaß"
),
discord.SelectOption(
label="Moderation",
description="Moderations Befehle"
),
discord.SelectOption(
label="Tools",
description="Tools wie z.b Google Übersetzer"
)
]
)
async def on_timeout(self):
self.disable_all_items()
await self.message.edit(content="You took too long! Disabled all the components.", view=self)
async def callback(self, select, interaction):
if "1" in interaction.data['values']:
await interaction.response("1")
if "2" in interaction.data['values']:
await interaction.response("2")
if "s3" in interaction.data['values']:
await interaction.response("3")
if "4" in interaction.data['values']:
await interaction.response("4")
class help(commands.Cog):
def __init__(self, bot):
self.bot = bot
@slash_command(
name="help",
description="Gibt das Hilfe Menü aus"
)
async def help(self, interaction: discord.Interaction):
embed=discord.Embed(title="Hilfe für Planetbot",description="Wilkommen im Hilfemenü von Planetbot")
embed.set_thumbnail(url="https://cdn.discordapp.com/attachments/1057042955711557743/1212507577972293673/Planetbot_Logo.jpg?ex=65f216ad&is=65dfa1ad&hm=bf34e1a25c7a8294664caecb68483b868737e7a6827fb1e925c28cab3d56e5b2&")
embed.set_footer(text=f"{MyView.is_persistent(MyView())}")
await interaction.response.send_message(embed=embed, view=MyView(),ephemeral=True)
def setup(bot):
bot.add_cog(help(bot))```
das ist der code
@sage tendon
8 tage später
https://guide.pycord.dev/interactions/ui-components/dropdowns das hier solltest du dir erstmal sowieso angucken
Learn all about implementing Select Menus or Dropdowns in your Discord Bot with Pycord.
ich will halt für jede option ein eigenes embed
hab ich
habs auch an hand dieser docs nach gebastelt
da steht genau drin, wie man den ausgewählten wert bekommt
und halt rumprobiert
change discord.Role type to commands.RoleConverter (from discord.ext import commands), and make sure your autocomplete roles use role IDs for the value
RoleConverter will automatically convert the variable into a role, or raise an error if the role isn't found (which you can then handle elsewhere)
muss ich das view eigendlich in einbe eigene class packen?
ok
also muss ich ne klasse haben die halt dememsprechend benannt ist
hast du doch schon alles
mit ner init datei?
sollte denke ich kein problem sein richtig?
nee py
...
alspo ich hab nen ordner dafür
__init__.py
wollte ne dropdown.py im ordner Utils erstellen
kannst du machen
dann kann ich mit from utils import help_view mir die class holen
die ich brauche
ist praktischer wenn alles an dropdownmenüs beisammen sind
from utils.dropdownmenu import Help_View```
so
importiert jezt sollte er aus der klasse die sachen ziehen können richtig?
und ich kann für jedes dropdown ein eigenes menü anlegen
ich kapier select menüs net
ich durchschaue es net so wirklich
Here's the dropdown example.
warum?
das importiert die klasse, nur Help_View
ich kriege es net hin das er das menü ausgibt
ctx.respond
You're the right person for this situation.
Thank you so much!
allgood
ich durchschaue immer noch net wie ich die ausgabe kriege
.
also die auswahl
genau wie es da steht. nicht anders.
hääääääääääh
wo steht das?
irgendwo muss ich was übersehen
ja toll ich will ja ein bestimmtes
soll ich vom select.values[0] den namen holen?
was bedeutet die 0 überhaupt?
select.values ist eine Liste
ja und?
...also ist 0 das erste Element in der Liste; Das ist normales Python
ok
also muss ich das so machen oder?
ja
if select.values[0] == "Info":```
👍
aaaaaaah
danke
bitte
interaction.edit(embed=...)
ok
ohah wie geil
lagere auch alle embeds ausserhalb
so kann ich in einer datei embeds hinzufügen und ändern wie ich witzig bin
embeds haben keine dateien :)
ich hab hald eine embeds.py
achso
wo alle embeds als variable gespeichert sind
ja ok wenn hier alle deutsch schreiben:
Gibt es so wie für das user select auch ein server select?
help_info_embed = discord.Embed(title="Informations Befehle",description="Alle Info Commands von Planetbot")```
so z.b
select nein, aber als typ funktioniert es
in optionen
aber ohne vorschläge
kannst du
einige haben variablen die ich erst im hauptcode kriege
z.b membernamen
dann mach eine methode draus und übergib die sachen
wie
was wie
wie ging das nocbhmal
hab jezt ne längere Pause gemacht
Verstehe
also dann wenn ich ne variable hab die dann in eine methode packen
return das embed
?
wie meinst du das ich kapiere grade überhaupt nichts
def get_embed(var):
return discord.Embed(...description=var)
kann ich beim botstop oder start alle exestierenden Buttons und selectmenüs unklickbar machen?

@ezcord.Cog.listener()
async def on_ready(self):
self.bot.add_view(CreateTicket())
self.bot.add_view(TicketView())
self.bot.add_view(CreateTicketSelect())
self.bot.add_view(QuestionsButton(self.ticket_owner))```` ```py
[ERROR] Error while sending error report to webhook. Please check if the URL is correct.
[ERROR] Error in event on_ready
Traceback (most recent call last):
File "C:\Users\Dark_Angel\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 400, in _run_event
await coro(*args, **kwargs)
File "C:\Users\Dark_Angel\Desktop\helper stern\cogs\ticket.py", line 72, in on_ready
self.bot.add_view(QuestionsButton(self.ticket_owner))
AttributeError: 'Ticket' object has no attribute 'ticket_owner'```
and without is like that
i mean
the error is quite clear
you're trying to access the ticket_owner attribute, but it doesnt exist
class QuestionsButton(discord.ui.View):
def __init__(self, ticket_owner):
super().__init__(timeout=None)
self.ticket_owner = ticket_owner```
that aint the ticket class
thats the questionsbutton class
read the error, it tells you exactly which object / class is meant
Why even ask here, while building with 'ezcord' instead of the CodingKeks server, that's were this library dev is.
Ezcord is build on top of pycord and you can't expect people here to know about it.
cause i know the server and some of their videos
selective attention and all that
even simpler?
ezcord is just an extension of py-cord
why ever someone wants that, i thought pycord to be pretty straight forward
okay, so it adds more functionallity?
I never really used it.
can anyone give me a quick example of check_any? mine isnt working for some reason
just know it exists
@commands.check_any([commands.is_owner(), commands.has_guild_permissions(administrator=True)])
thats not how that works for all i know
yes
hmmmn. alright then I guess.
I just assumed it'd dumb down things a bit more, cause the videos are mainly targeted towards new devs.
my bad
(don't get me wrong, i liked the pycord tutorials the guy had)
that's the example the docs provided:
def is_guild_owner():
def predicate(ctx):
return ctx.guild is not None and ctx.guild.owner_id == ctx.author.id
return commands.check(predicate)
@bot.command()
@commands.check_any(commands.is_owner(), is_guild_owner())
async def only_for_owners(ctx):
await ctx.send('Hello mister owner!')
thanx you
Welcome
as far as i understood it, check any takes as many arguments as you like checks them with
or
and lets your slash command run if at least one of your conditions is True.
never used the thing persoanlly though
The following section outlines the API of Pycord’s prefixed command extension module. Bots: Bot: Attributes activity, allowed_mentions, application_flags, application_id, cached_messages, case_inse...
hi guys, how can I best have the ticket deleted after 12 hours?
yep io wanted a command to be available if i have admin on a server or im the owner of the bot, but for some reason it isnt working for me rn... will keep looking into it
you passed it in an array, but it takes bare args if maven got it right
store them with a timestamp. create a task loop that's run every 15 minutes and loops through tickets and delets them if timestamp now - ticket-timestamp is more than 12h?
i could show you an alternative way thats simpler, while a tiny bit less elegant if you like.
have something along those lines in my own bot.
aha! i found the issue
remove the ()
what i was doing before was having some ifs inside the code, but i wanted to move to checks since it seems its the intended way to do it
which ones?
no worries
for me it was the other way around, cause i wanted the command to respond in such cases too. like: you need xy permissions for this command. please talk to an admin.
sure, you could also include some such thing in the error handler, but why raise errors through a decorater to then handel them and jump through hoops to answer in the error cases. with ApplicationContext there already is everything needed to send a response and users can see what commands the bot offers, if allowed by integration settings.
Good free advertisement
However, if you build a more elegant way, I'd be glad to see an example of your solution. maybe you come up with sth. I didn't think about.
Fwiw you don't need to do it in the global error handler, each command has its own overridable one that ignores global if it exists
I personally have a generic checkfailure in global that has a button linking to a youtube video of korone falcon punch
😂 Love the idea!
wie nuzt man das?
Learn all about Context Menus (User Commands & Message Commands) and how to implement them into your Discord Bot with Pycord!
This member has received no warnings.
I feel like a complete idiot asking this question but I've been through the docs and done a little googling and can't find anything so: how do I access the channel type for a message passed through on_message?
I've tried type(message.channel) and message.channel.type with no avail.
For those who want to know what I found on the docs, I went in a circle around:
https://docs.pycord.dev/en/stable/api/models.html#discord.Message.channel
https://docs.pycord.dev/en/stable/api/models.html#discord.Interaction.message
https://docs.pycord.dev/en/stable/api/models.html#discord.DMChannel
and then ended up at the start without being able to find any properties that were close to channel types :/
Thanks :p
discord.ChannelType
discord.ChannelType.category
discord.ChannelType.directory
discord.ChannelType.forum
discord.ChannelType.group
discord.ChannelType.news
discord.ChannelType.news_thread
discord.ChannelType.private
discord.ChannelType.private_thread
discord.ChannelType.public_thread
discord.ChannelType.stage_voice
discord.ChannelType.text
discord.ChannelType.voice
discord.DMChannel.type
discord.TextChannel.type
^ this is what message.channel.type should give
I'll take a look and see what I find, thanks :)
Turns out: I'm a complete idiot
I was using message.channel.type is discord.ChannelType.private instead of the == operator 💀
Thanks for the docs tho
yeah
guild = interaction.guild
member = discord.utils.get(guild.members, name=self.username)
await member.kick(reason="Denied verification")
What am I doing wrong 😭 😭
for starters you didn't provide any error 
mb give a sec, i assumed whatever I was doing wrong was completely obvious
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
full traceback?
doesn’t hurt to confirm
use ctx.defer()
you don’t even know if they are using ctx or interaction
I was actually wrong but then again still right but less so than when I initially thought I was right
Traceback (most recent call last):
File "/home/apolloactive/.local/lib/python3.9/site-packages/discord/ui/view.py", line 426, in _scheduled_task
await item.callback(interaction)
File "/home/apolloactive/Desktop/piProjects/testingFile.py", line 92, in button_callback
await interaction.response.send_modal(MyModal(title="Verify!"))
File "/home/apolloactive/.local/lib/python3.9/site-packages/discord/interactions.py", line 1178, in send_modal
await self._locked_response(
File "/home/apolloactive/.local/lib/python3.9/site-packages/discord/interactions.py", line 1243, in _locked_response
await coro
File "/home/apolloactive/.local/lib/python3.9/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
here
piProjects lol
its not member.kick, it is guild.kick(member)
anyways, your modal taking more than 3 seconds to send
ignore 😭
@civic quiver
verification stuff is a bit annoying because there can be a big timeframe in-between things
alr
Can you provide more code as to what you are doing so we can look into how to decrease response time?
both exist
wasnt aware
well now you do
let me see if I can fix on my own now that I know what the problem is before i put my shit late night code here and give somebody a heart attack
whats the difference between the two?
none in functionality
they specified a member object
I think maven just meant in general
ahhh don't worry, squid needs some spaghetti code once in a while,
it's about the same as it is with coffee for others 
most times he even does some magic with it
yeah
thanks for the info though. always happy to learn sth, new!
please don't take those things serious when I say them. I really like what you're doing here.
making some dark magic references and such is just humorous way to acknowledge how well you know the docs.
(can seem like magic at times :D)
i don't mind what you said lol
alr i dont know now :Sob:
class StaffVerify(discord.ui.View):
def __init__(self, username, *args, **kwargs):
super().__init__(*args, **kwargs)
self.username = username
@discord.ui.button(label="Approve", style=discord.ButtonStyle.green)
async def approve_button_callback(self, button: discord.ui.Button, interaction: discord.Interaction):
guild = interaction.guild
member = discord.utils.get(guild.members, name=self.username)
verified_role = discord.utils.get(guild.roles, name="Verified")
if member:
await member.add_roles(verified_role)
await interaction.response.send_message(f"Successfully verified {member.display_name}!", ephemeral=True)
else:
await interaction.response.send_message("Member not found.", ephemeral=True)
@discord.ui.button(label="Deny", style=discord.ButtonStyle.red)
async def second_button_callback(self, button: discord.ui.Button, interaction: discord.Interaction):
guild = interaction.guild #im going to take my own life i stg
member = discord.utils.get(guild.members, name=self.username)
interaction.response.defer()
await member.kick(reason="Denied verification")
And recent traceback:
Traceback (most recent call last):
File "/home/apolloactive/.local/lib/python3.9/site-packages/discord/ui/view.py", line 426, in _scheduled_task
await item.callback(interaction)
File "/home/apolloactive/Desktop/piProjects/testingFile.py", line 56, in second_button_callback
await member.kick(reason="Denied verification")
AttributeError: 'NoneType' object has no attribute 'kick'
is the problem not finding the user? is it a permissions thing?
well that user isn't in the guild anymore or just not cached
why do you use their name and not their ID?
name is not unique long term
early in dev, i chose this and i wanna figure it out bc im this far, planning on changing it anyways later
when i kick i do get user first, with their ID or through guild members.
then i check if the member is none.
when it is none i fetch
when it is not none i check if it is type discord.member or user (if he left the guild its user, so return)
same none check if i fetched ofc.
i know a bit overkill, but it works 😄
*first line depends on the input source and the method doing the kicks
yeah ill just take toothys advice and just switch, will be worth rewriting stuff later down the road anyways lmao
yeah names are a bad source to start with
It's still a good idea to have a none check, cause it can be none or .user for several reasons
yea always do if not var:, never trust gets, and only limitedly trust fetches too
alr, next question is how do I get the user id from a modal submission
see I didnt know how to get that info, so for testing I just had the first input field have the username, and took the value from that
modals are interactions too so I would be surprised if it's not just interaction.user.id
welp lets see
Is there a way to send modals using a followup webhook? My command's response gets deferred to prevent it from timeout, but I'd like to send a modal a bit later.
did you try it?
I'll admit I'm new to modals, but since I can send one via interaction.response.send_modal() and followups only have followup.send() without modal parameter, I'm not sure how I should send it. Should I try followup.send(modal)?
you can only use the response.send_modal()
Alright, so no followups
yes
Got it, thanks a lot!
@errant trout Help me in the latest poll creation feature in discord
how can i use that in pycord
like reference
its not supported yet by pycord but you can make a pr
pr?
This code works but I get The application did not respond errors from it.
import discord
from dotenv import load_dotenv
import os
load_dotenv()
TOKEN = os.getenv("DISCORD_TOKEN")
bot = discord.Bot()
@bot.slash_command(name="echo", description="echoes")
async def echo(ctx, channel:discord.TextChannel, *, message):
await channel.send(message)
bot.run(TOKEN)
Is there something I can use in place of the channel.send?
you have to respond to the slash command
await ctx.respond("TEXT")
Thanks, it disables the error, but when I tested it, it removed the ability to have that message be sent to that particular channel chosen with channel:discord.TextChannel
Yes, also thanks! I didn't know the * was unnecessary.
I updated to this but I can't get it to echo to another channel yet
import discord
from dotenv import load_dotenv
import os
load_dotenv()
TOKEN = os.getenv("DISCORD_TOKEN")
bot = discord.Bot()
@bot.slash_command(name="echo", description="echoes")
async def echo(ctx, channel:discord.TextChannel, message):
await ctx.respond(message)
bot.run(TOKEN)
why did you remove the channel send?
😄 I thought the ctx.respond had to take the place of it...
Doing the await ctx.respond("TEXT") works to prevent the error after the channel.send but is there any way to have the bot not say anything after a slash command?
Or is it a must? Either error or text response?
import discord
from dotenv import load_dotenv
import os
load_dotenv()
TOKEN = os.getenv("DISCORD_TOKEN")
bot = discord.Bot()
@bot.slash_command(name="echo", description="echoes")
async def echo(ctx, channel:discord.TextChannel, message):
await channel.send(message)
await ctx.respond("TEXT")
bot.run(TOKEN)
Thanks btw!
yes, all slash commands need a response of some kind
in your example, it would be nice to send a link to the message that was echoed
wie frage ich die administrator berechtigung ab?
Thanks, great idea!
I'll make it ephemeral too since I didn't want it to be seen
member.guild_permissions.administrator
ok
dachte über die discord.commands.permissions
Traceback (most recent call last):
File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\cog.py", line 778, in _load_from_module_spec
spec.loader.exec_module(lib) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap_external>", line 995, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "C:\Users\leonf\PycharmProjects\Planetbot\cogs\help.py", line 5, in <module>
from utils.dropdownmenu import Help_View
File "C:\Users\leonf\PycharmProjects\Planetbot\utils\dropdownmenu.py", line 4, in <module>
from utils.embeds import *
File "C:\Users\leonf\PycharmProjects\Planetbot\utils\embeds.py", line 8, in <module>
s = speedtest.Speedtest()
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\speedtest.py", line 1095, in __init__
self.get_config()
File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\speedtest.py", line 1127, in get_config
raise ConfigRetrievalError(e)
speedtest.ConfigRetrievalError: HTTP Error 403: Forbidden
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\leonf\PycharmProjects\Planetbot\main.py", line 127, in <module>
bot.load_extension(f'cogs.{cog}')
File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\cog.py", line 912, in load_extension
self._load_from_module_spec(spec, name)
File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\cog.py", line 781, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'cogs.help' raised an error: ConfigRetrievalError: HTTP Error 403: Forbidden
warum plötzlich
speedtest is nicht pycord
ist aber im bot
super, hat nichts mit pycord zu tun
könnte das am neustart liegen
hab grade den bot ween pycord problemen 7 mal neugestartet

you have different permissions when a user uses a command.
For example;
within a slash command you are allowed to send a response to the slash command. at the same time you can have different channel permissions and can even run into errors when trying to delete or edit your own message later on (outside of the scope of the slash command).
therefore there is different ways to check for permissions.. they differ on context
There are over 400 timezones
How would you design a discord timezone bot? Can slash commands or anything handle over 400 options?
lol
option: timezone
or do you wanna
GMT+0: boolean
GMT+1: boolean
...
If you mean values for options, yes, with autocomplete
discord handles timezones when you post timestamps correctly formated. it'll display them converted to local time to each user. so you can simply use timestamps and include them in your messages.
That... makes sense
also there are not 400 timezones
I should have been more clear, im making a habit tracker discord app. When the day is over for a timezone I want to not allow a user to mark that day for that habit. So I need to know their timezone or at least let them pick it
What are those called? The super specific ones for each country. There's gotta be at least 200. Not sure the namr
thats not how timezones work
So how do they work? Im just starting this bot so I want to clear my misconceptions
there are currently 38 timezones in the world
technically there are that many yes
go import zoneinfo and print zoneinfo.available_timezones(), they work on country/city basis even if in practice there's only a handful
But whst if in hawaii they have daylight savings, that messes up with the 38. So then every country has day savs and then it messes up my gmt selection
That doesn't change the timezone, though ;)
True
Does the city selection also make it account for DST?
But then i have to deal with like 300 day savs
probably
Interesting
You are currently finding out why devs around the world hate time, timezones, and anything related to time
if you want a list of all timezones for use in autocomplete without installing any other libraries, use list(zoneinfo.available_timezones())
you can plug the value they select back into a zoneinfo.ZoneInfo class, which is directly compatible with the datetime library
BUT with autocomplete you NEED to verify the input value, it does not verify the user input to be an entry of the list you give them
otherwise pytz is a more extensive timezone library
Yup. I'm now more confused than I started. I might fall back on your GMT+0: boolean, etc suggestion
That's cool! Will try it out, thanks
Thanks noted
no wtf that was a joke lmao
don't do that
no
just because someone uses a certain language doesn't mean they also have the appropriate timezone, if there even is just one
I am only making this for about 20 people so it won't be a big bot. I just might let them select their gmt and call it a day. 🥲
That is my last resort if autocompletion with slash commands is a pain
That's clever though 🥲
autocomplete is easy enough, it's just how you handle the timezone after
yea, but not like that
Ignoring exception in command levelboard:
Traceback (most recent call last):
File "/home/container/.local/lib/python3.9/site-packages/discord/commands/core.py", line 127, in wrapped
ret = await coro(arg)
File "/home/container/.local/lib/python3.9/site-packages/discord/commands/core.py", line 911, in _invoke
await self.callback(ctx, **kwargs)
File "/home/container/bot.py", line 552, in levelboard
em.add_field(name=f"{count}. {user.name}", value=f"Level {table[0]} | XP {table[1]}", inline=False)
AttributeError: 'NoneType' object has no attribute 'name'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/container/.local/lib/python3.9/site-packages/discord/bot.py", line 1008, in invoke_application_command
await ctx.command.invoke(ctx)
File "/home/container/.local/lib/python3.9/site-packages/discord/commands/core.py", line 359, in invoke
await injected(ctx)
File "/home/container/.local/lib/python3.9/site-packages/discord/commands/core.py", line 135, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'NoneType' object has no attribute 'name'
@Client.bridge_command()
async def levelboard(ctx):
async with Client.db.cursor() as cursor:
await cursor.execute("SELECT levelsys FROM levelsettings WHERE guild = ?", (ctx.guild.id,))
levelsys = await cursor.fetchone()
if levelsys:
if not levelsys[0] == 1:
return await ctx.respond('This server has not enabled leveling.')
await cursor.execute("SELECT level, xp, user FROM level WHERE guild = ? ORDER BY level DESC, xp DESC LIMIT 10", (ctx.guild.id,))
data = await cursor.fetchall()
if data:
em = discord.Embed(title="Leveling LeaderBoard")
count = 0
for table in data:
count += 1
user = ctx.guild.get_member(table[2])
em.add_field(name=f"{count}. {user.name}", value=f"Level {table[0]} | XP {table[1]}", inline=False)
return await ctx.respond(embed=em)
return await ctx.respond("No one has leveled up yet.")
For some reason my bot keeps popping up that error for one server but not the other ones anyone know why?
Whichever user youre trying to get is None
It is not getting a specific user it is getting all in the database.
IS there a way that I can make it so it removes a user if they leave?
Listen to the member remove event?...
The autocomplete took me like an hour to make, could you critique if my autocomplete code is any good please?
https://discord.com/channels/881207955029110855/1228126158466580490
alr so I'm havin some problems with cog loading
for sub_folder in cogs_json["sub_folders"]:
for file in cogs_json["sub_folders"][sub_folder]["files"]:
file_path = os.path.abspath(f"{cogs_folder}/{sub_folder}/{file}")
print(f"Loaded {file_path}")
bot.load_extension(file_path)
gives an error of:
ModuleNotFoundError: No module named 'C:\\Users\\me\\PycharmProjects\\nestlingRewrite\\cogs\\games\\2048'
I tried doing a relpath
but that didn't work
I also tried adding and removing .py from the 2048 name
file structure looks like this:
load_extension uses python import formatting
so something like cogs.games.2048
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooh
tysm!
Is there a way to explicitly unregister a slash command? I have a test version of my bot in my server to test new features before I add it to the production version of the bot, so every slash command shows up in the menu twice (once for each instance of the bot). They stick around even long after the bot stops running.
You can with
https://docs.pycord.dev/en/stable/api/clients.html#discord.Bot.remove_application_command
And
https://docs.pycord.dev/en/stable/api/clients.html#discord.Bot.sync_commands (specify the specific commands)
This is not recommended as there is a rate limit of 200 application command registers a day so if you are constantly restarting your test bot and re-registering commands unnecessarily you will get rate limited
Bots: Attributes activity, allowed_mentions, application_flags, application_id, auto_sync_commands, cached_messages, cogs, debug_guilds, description, emojis, extensions, get_command, guilds, intent...
i see, is there any alternative option i should be doing? I feel like this ought to be a common issue
It won't fix it for you but you can fix it for other users by disallowing users from being able to use specific commands in the integration settings
(Admins will always be able to see/use commands)
hmm, yea i have 2 admins in my server that I would like to prevent having this issue. I'll never be confused which command belongs to which bot, but they might
I can't remember exactly. I think it is connected specifically to the manage server permissions
lazily i just have the "administrator" permission for both of them. So are you suggesting that if I explicitly give them every permission except the "administator" perm and "manage server" perm, I could disallow them from seeing the commands from the test bot?
Run bot.sync_commands with an empty list to remove all of them
i am leaning towards that, though 200 command registers a day is really small. If i'm testing the bot, i'm constantly restarting it
Ehh it should be fine, probably
You only need to restart if you are changing command metadata
If it's just the logic/callback, reloading the cog is enough
i don't actually have anything setup with cogs yet, I essentially just have an on_message listener and a handful of slash commands in a single module. I don't know much about cogs yet or how i'd restart just the cog
Cogs aren't necessary, but i would generally recommend them for the convenience of isolating features and being able to manage them separately
Here's the slash cog example.
I started to use only cogs and not a single file anymore
You can still keep stuff in your main bot file of course, so generally you'd keep stuff you aren't changing often there
i would definitely like to move towards cogs
where would you suggest I invoke bot.sync_commands? Would it make sense to put it in this finally clause? https://github.com/fiskenslakt/pzsd-bot/blob/e53881f5e75c991305212762dbe2043958bc60a7/pzsd_bot/__main__.py#L293
...probably? Whatever works
Though if you're doing continuous testing, you might want to do the de-sync manually
That way you can run it a single time at the end when you're finished for the day
hmm yea, so maybe like create a !sync command even?
to have normal non-slash commands, i have to do something different with how i'm handling the on_message listener right?
Did you override it as event or did you use bot.listen
i just decorate it with bot.event
ah yes, this is what i remembered reading at one point
I checked and it is actually possible but not as easy as Bot.change_presence(status=Status). You have to tell discord that you are an Android or iOS device. You can do that by changing the browser value in DiscordWebSocket.identify() to Discord Android or Discord iOS. But since the identify method is only called once, when establishing the websocket connection, you can't really change that dynamically like you can with change_presence.
Unless it is possible to identify multiple times...
You can spoof it, but the library does not support it as it's not a feature
how to get the user local ?
any solution ?
Target not found, try again and make sure to check your spelling.
.rtfm locale
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 interaction.locale
This is pycord. Not discord.py
there is pycord
if its ctx.local, it mean there are an error on the description
What?
Returns the locale of the guild associated with this context's command.
Shorthand for .Interaction.locale.
yea they're kinda right
also, it's locale
@errant trout
remove dpy still same error
reinstall pycord
? locale is correct
interaction.locale says it's the user locale
this says otherwise
its more about the description, ctx.local is the local of the user, however it say in the description the guild
Guilds don't have a region anymore
yep nothing more important
k kk
since when ?
Like years ago
so like ctx.guild_locale will be None ?
region != locale
locale
what the difference ?
There's a lot of different interpretations here
local means here
locale means language
no but like between locale and region
in this context
region is just EUW, Asia, USW/USE
well it doesnt exist anymore
Ok summary - years ago, guilds used to have a "region" which was used for all voice channels, but now individual voice channels have their own region
The language set in community is guild.preferred_locale, which is also equal to interaction.guild_locale
i see know, thanks you a lot
but if a guild doesnt have a community ?
it will be a default thing or return None ?
i will finish my class and try and tell u
r/USdefaultism??
ich möchte gerne seiten für Changelogs erstellen und diese dann mit knöpfen umblättern lassen können wie setze ich das am besten um?
paginator
was war das nochmal
und ich hab unterschiedliche changelog zahlen das stört nicht oder?
lesen und verstehen und ausprobieren
ohah
das ist ja der hammer
das macht allles ja super Easy
Pycord ist absolut klasse
Ich sehe die Deutschen sind wieder am übernehmen von dem Help Channel xd
hehehe
bin froh das hier welche deutsch sprechen
ist einfacher für mich
kann ich bei den embeds auch irgendwie add_field nutzen=
warum nicht
wie?
ich verstehe es doch noch nicht so ganz
ääääääh
habe grade das hier:
@slash_command(name="changelogs",descriptions="Alle Chagelogs des Bots")
async def changelogs(self,ctx):
pages = [
Page(embeds=[discord.Embed(title="Changelog von Planetbot V0.0.1 vom 27.01.24", color=discord.Color.yellow(),description="🟢 /guternmorgen\n"
"🟢 /gutenacht\n"
"🟢 /hello\n"
"🟢 /countdown\n"
"***Legende:*** Hinzugefügt:🟢, Entfernt:🔴, Änderungen:🛠️\n")])
]
paginator = Paginator(pages=pages, author_check=True, disable_on_timeout=True)
await paginator.respond(ctx.interaction)```
embed = Embed()
embed.add_field(...)
...
my_pages = [Page(embeds=[embed])]
Hello, trying to use this code to assign multiple roles to a person, but the selection box only allows me to pick a single role- anyone know what I'm doing wrong?
@slash_command(name='giverole2', description="Assign multiple roles to a user")
async def giverole2(self, ctx,
user: Option(discord.Member, "Select the user", required=True),
roles: Option(discord.Role, "Select the roles", required=True, max_values=25,
min_values=1, autocomplete=None)):
"""A command to give multiple roles to a specified user."""
if not ctx.guild.me.guild_permissions.manage_roles:
await ctx.respond("I do not have permission to manage roles in this server.")
return
added_roles = []
denied_roles = []
already_assigned = []
for role in roles:
# Ensure the role is below the bot's highest role in the hierarchy
if role >= ctx.guild.me.top_role:
denied_roles.append(role.name)
continue
# Check if the user already has the role
if role in user.roles:
already_assigned.append(role.name)
continue
# Try to add the role
try:
await user.add_roles(role)
added_roles.append(role.name)
except Exception as e:
await ctx.respond(f"Failed to assign the role '{role.name}': {str(e)}")
return
response_message = ""
if added_roles:
response_message += f"Successfully assigned the roles: {', '.join(added_roles)} to {user.display_name}.\n"
if already_assigned:
response_message += f"{user.display_name} already has the roles: {', '.join(already_assigned)}.\n"
if denied_roles:
response_message += f"Cannot assign roles higher or equal to my highest role: {', '.join(denied_roles)}."
await ctx.respond(response_message or "No roles were changed.")
ok ich versuchs mal
you can't select multiple things for an option
What you probably want is a view attached to a message that has a select box to choose multiple roles from
and max_values isn't a thing, it's max_value and intended to limit the number you can put in there if it's an int, not the amount of selections
Ahhhh, okay.
and, just a heads up, if you wanna do selfroles, please use discord's onboarding feature
its 100000x easier than doing it with a bot
Nah, this is more designed for server moderation- staff giving roles through the bot, as opposed to assigning the roles straight through Discord- client wants a nicer-looking paper trail, so I'll eventually be doing embeds with the results, etc.
well, depending on the amount of roles expected to be assigned at once, you could do it with multiple optional options role1, role2... but thats a bit hacky
but easier than a whole select menu
The (hopeful) idea was something like
/giveroles @usermention, Role1, Role2, Role3 etc
well, you can do that, it just needs to be seperate options, not a single one
Ah, okay, so make the first role choice mandatory and the rest optional?
yea
hast du ne iddee warum paginator es nicht scchaft sich das embed von der anderen importierten Python datei zu holen?
da kommt es sei nicht definiert
screenshot
joa.. bisschen mehr details wäre gut
description* :)
hups
ja IDE unterstreichts nicht, also wo kommt der fehler
Ignoring exception in command changelogs:
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\info.py", line 99, in changelogs
Page(embeds=[changelog_embed])
^^^^^^^^^^^^^^^
NameError: name 'changelog_embed' is not defined
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: NameError: name 'changelog_embed' is not defined```
muss ich explizit das embed importieren?
vieleicht
deinem import zufolge wäre "utils" ein ordner, der eine datei names embeds enthält.
Kopfkratz
ja
genau so ist es
bei allen anderen klappt es auch
also er holt sich das embed aus der Datei
Wenn es bei anderen geht machst du ja wohl irgendwas anders
dann solltest du autocomplete bekommen, wenn du statt * chang... schreibst und tab drückst.
bekommst du das nicht wirds nicht gesehen.
Accept roles as a string option and mention each role, then you can use discord.utils.raw_role_mentions to get all role IDs in the string
Finally guild.get_role them
autocomplete findet es
yea i wasnt sure on whether to suggest that as well because its a little janky lol, but ig it works
wenn es damit, also dem direkt eingetragenenen namen statt * immernoch nicht geht zeig doch mal das embed selbst
geht net
warte
changelog_embed = discord.Embed(title="Changelog von Planetbot V0.0.1 vom 27.01.24")```
description haste auch drinne?
nein
brauch ich die?
häh
pack mal
, description = " TEST "
hinter dein 2. Anführungszeichen und probier nochmal aus
zeigen
zeig mal was genau du gemacht hast, meine Glaskugel ist in der reparatur
😂 zeig doch einfach
was?
na was genau du geändert hast
nen problem..
könnte es sein das der bot geblockt wurde
das weißt nur du
weil ich ihn grade oft neustarte
woher soll ich das wissen?
woran erkenne ich das der bot nen api block oder so hat?
daran das nichts mehr geht?

ich kann nichts mehr ausführen och maaaaan
dann zeig halt keinen code, ich laufe dem bestimmt nicht hinterher.
welchen
ich hab viel
es ist nen riesen bot
Oh Mann!
Das Embed Mensch
changelog_embed = discord.Embed(title="Changelog von Planetbot V0.0.1 vom 27.01.24")```
dann lese nochmal meine Nachricht dazu!
Hier @vestal folio
ja habe es noch nicht geändert gehabt

weil grade gar nichts geht
😂
na wenn deine IDE abstürzt könnnen wir da auch wenig tun
I am amused way waaay to easily
die läuft
bot ist auch online
log lesen
ich starte mal den Laptop neu
hmh
ich warte erstmal
keine ahnung warum aber er läd nicht mehr
vieleicht darf ich später wieder
when can i see all the different preferred_locale that a guild can have ?
oder log lesen
i just have to ask, WHY would you even need the guild locale
for a translation module, for fr local has french, etc etc
habe kaum welche
but since i dont know the other it a bit more difficult
Möglich dass du es irgendwie hinbekommen hast dass dein bot heute zu viele commands registriert hat
hier hast du den blöden log:
04-12-2024-34-34-34 WARNING PyNaCl is not installed, voice will NOT be supported
04-12-2024-34-34-34 INFO logging in using static token
04-12-2024-35-34-35 INFO Shard ID None has sent the IDENTIFY payload.
04-12-2024-35-34-35 INFO Shard ID None has connected to Gateway: ["gateway-prd-us-east1-c-wpfc",{"micros":80830,"calls":["id_created",{"micros":816,"calls":[]},"session_lookup_time",{"micros":371,"calls":[]},"session_lookup_finished",{"micros":12,"calls":[]},"discord-sessions-prd-1-206",{"micros":77965,"calls":["start_session",{"micros":38684,"calls":["discord-api-rpc-775f6f4b57-48n5g",{"micros":35198,"calls":["get_user",{"micros":6314},"get_guilds",{"micros":2669},"send_scheduled_deletion_message",{"micros":6},"guild_join_requests",{"micros":0},"authorized_ip_coro",{"micros":6}]}]},"starting_guild_connect",{"micros":70,"calls":[]},"presence_started",{"micros":245,"calls":[]},"guilds_started",{"micros":71,"calls":[]},"guilds_connect",{"micros":1,"calls":[]},"presence_connect",{"micros":38842,"calls":[]},"connect_finished",{"micros":38847,"calls":[]},"build_ready",{"micros":18,"calls":[]},"clean_ready",{"micros":0,"calls":[]},"optimize_ready",{"micros":25,"calls":[]},"split_ready",{"micros":1,"calls":[]}]}]}] (Session ID: b088dbec0171f2a4e6be05523c7c2666).
04-12-2024-36-34-36 WARNING We are being rate limited. Retrying in 394.60 seconds. Handled under the bucket "None:917174972588392499:/applications/{application_id}/guilds/{guild_id}/commands"
04-12-2024-37-34-37 INFO
----------------------------------------------------------------
Saturnbot Logs
----------------------------------------------------------------
Der Bot mit dem Namen "Blue_Gamer48" wurde erfolgreich gestartet!
Discord.py Version: 2.5.0
Python Version: 3.12.3
Operating System: Windows 11 (nt)
----------------------------------------------------------------```
..
uff
och nööö
und nur die bekloppte api weiß wann ich freigeschaltet werde
hm
genug zeit um mit prints etc deinen fehler zu finden und zu beheben
dann schreib's auch hin :>
warum er das als discord.py erkennt keine ahnung
Liest du deine Error Codes eigentlich??
das sind halt 3 zeilen, mach das halt selber neu falls du dafür irgendein package benutzt
Nein
DU glaubst nicht WIE ICH MIR DAS BEI VIELEN WÜNSCHEN WÜRDE
das sollte denke ich die 6-7 minuten dauern
hab aber auch den bot in 5 minuten 8 mal neugestartet
Es gibt so viele die NICHT die Fehlermeldung lesen
😂 Ich bekomme so langsam eine waage vorstellung davon
oder mehr
Idee
Bei jeder nachricht bei der das wort traceback enthalten ist, den codeblock (oder sonst die ganze nachricht) zur kostenlosen gemini api ballern und nach einer ganz kurzen, SEHR einfachen fehlerbeschreibung fragen, und dann mit einem bot antworten
Du glaubst gar nicht was hier teilweise abgeht...
.js.py und so 
oder du versuchst halt deinen fehler zu finden in der zwischenzeit
dafür brauchst du nichtmal internet
ja dann versuch es zu beheben :>
wie wär es mit import utils.embeds und dann embeds.name
ich muss es mit * importeren
da es sonst probleme mit anderen embeds Murks gibt
dann solltest du das vielleicht gleich mit beheben
oder du importiest nur das eine embed
s = speedtest.Speedtest()
s = s.results.dict()
botinfo_embed = discord.Embed(title=f"Botinfo von Planetbot")
botinfo_embed.add_field(name="Name:", value=f"{bot.user.name}",inline=False)
botinfo_embed.add_field(name="Botinhaber",value="Blue_Gamer48")
botinfo_embed.add_field(name="Bot Version",value="2.0.0-Dev",inline=False)
botinfo_embed.add_field(name="Programmiersprache",value=f"Python",inline=False)
botinfo_embed.add_field(name="RAM:",value=f"{psutil.virtual_memory()[2]}")
botinfo_embed.add_field(name="Prozessorkerne:",value=f"{psutil.cpu_count()}",inline=False)
botinfo_embed.add_field(name="Programmiersprachen Version",value=f"{platform.python_version()}",inline=False)
botinfo_embed.add_field(name="Bibiliotek und Version",value=f"{discord.__version__}",inline=False)
botinfo_embed.add_field(name="Betriebsysystem und Version",value=f"{platform.system()} {platform.release()} ({os.name}",inline=False)
botinfo_embed.add_field(name="Bot:",value=f"{s['client']['isp']}() {s['client']['country']} {s['client']['isprating']}")
botinfo_embed.set_footer(text=f"Ein Bot von Blue_Gamer48 :copyright:2024 Planetbot")```
Ich benutze * nur bei einer init file
eieiei
alter
lösch das bitte
ja
ich wenn codeblock
reparier es grade
entferne die Nachricht bitte
ich kann das alles nicht mehr
warum überhaupt 😂
Deswegen schau ich auch immer weniger hier rein
jezt
infos holen
ja ok aber was juckt uns ein komplett anderes embed
das ist der grund weshalb ich das mit * importiere
das embed macht mist
wenn du mit * importierst machst du was falsch, aber grundlegend
"*" nur bei einer init file
habs versucht aber es wirft fehler warte
wie meinst du?
__init__.py
Ja ist schon klar
der code für die felder wird nie ausgeführt wenn du es nicht mit * importierst
aber dann mach halt ne funktion draus oder was weiß ich
from data import *
from data import _
the _ function will work however,
from data import *
the _ function will not work (undified)```
wo soll ich das nutzen?
Traceback (most recent call last):
File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\cog.py", line 778, in _load_from_module_spec
spec.loader.exec_module(lib) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap_external>", line 995, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "C:\Users\leonf\PycharmProjects\Planetbot\cogs\info.py", line 6, in <module>
from utils.embeds import botinfo_embed
ImportError: cannot import name 'botinfo_embed' from partially initialized module 'utils.embeds' (most likely due to a circular import) (C:\Users\leonf\PycharmProjects\Planetbot\utils\embeds.py)
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\cog.py", line 778, in _load_from_module_spec
spec.loader.exec_module(lib) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap_external>", line 995, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "C:\Users\leonf\PycharmProjects\Planetbot\cogs\fun.py", line 14, in <module>
from utils.embeds import *
File "C:\Users\leonf\PycharmProjects\Planetbot\utils\embeds.py", line 9, in <module>
from main import bot
File "C:\Users\leonf\PycharmProjects\Planetbot\main.py", line 127, in <module>
bot.load_extension(f'cogs.{cog}')
File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\cog.py", line 912, in load_extension
self._load_from_module_spec(spec, name)
File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-```
py3.12\Lib\site-packages\discord\cog.py", line 781, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'cogs.info' raised an error: ImportError: cannot import name 'botinfo_embed' from partially initialized module 'utils.embeds' (most likely due to a circular import) (C:\Users\leonf\PycharmProjects\Planetbot\utils\embeds.py)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\leonf\PycharmProjects\Planetbot\main.py", line 127, in <module>
bot.load_extension(f'cogs.{cog}')
File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\cog.py", line 912, in load_extension
self._load_from_module_spec(spec, name)
File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\cog.py", line 781, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'cogs.fun' raised an error: ExtensionFailed: Extension 'cogs.info' raised an error: ImportError: cannot import name 'botinfo_embed' from partially initialized module 'utils.embeds' (most likely due to a circular import) (C:\Users\leonf\PycharmProjects\Planetbot\utils\embeds.py)
Process finished with exit code 1```
warum eigentlich "value" und nicht description??
Und zu dieser Zeile habe ich dir vorhin schon was geschrieben:
botinfo_embed = discord.Embed(title=f"Botinfo von Planetbot")
wenn ich versuche das botinfo embed alleine zu importieren
SEHR GUT!
Du hast eine Fehlerquelle eingegrenzt.
Löse sie, ehe du was anderes änderst
ImportError: cannot import name 'botinfo_embed' from partially initialized module 'utils.embeds' (most likely due to a circular import`````
was meint er damit?
ah hab ne vermutung
muss nicht so sein, aber python meint das ist wahrscheinlich
glaube zu wissen was ich versemmelt hab
habs gefunden
jezt importiere ich explizit die embeds
die ich brauche
leider muss ich immer noch warten
da ich immer noch limitiert bin
von der beknackten api
die 8 minuten sind mittlerweile rum
ist also ein neues ratelimit
herzlichen glückwunsch
288
was wie?
die zeit vom alten ist abgelaufen also muss es wohl jetzt ein neues sein
jezt 2 mal
ja das weißt nur du
Vom error her könnte meine vermutung stimmen, dass du es irgendwie geschafft hast zu viele commands an einem tag zu registrieren
das wäre eine glanzleistung mit note 6
wie?
Gute frage
werden beim neustart alle commands neu regestriert?
nein
Limit von 200 commands pro tag, meines wissens nach, weiß nur nicht ob alle commands vom bot neu registriert werden wenn du einen änderst, oder nur der command
habe aktuell nur changelog neu
also komplett neu hinzugefügt
alle anderen sind voher da
gestern ist einer sogar rausgeflogen
wie viele commands hast du
äääääh keine ahnung
etwar 25

I'm installing the dev version but it installs as UNKNOWN rather than py-cord. Does anyone know how I can fix that?
python3 -m pip install git+https://github.com/Pycord-Development/pycord
as per the official repo :>
That's where the issue originates from.
upgrade pip
(also i think the url is meant to end in .git, can't remember)
Thank you so much.
One more question, I'm getting a deprecation warning for Option, saying I have to use BrideOption.
I'm not using bridge commands.
literally the same thing happened to me yesterday and i saw i was on v21 when latest was v24 LOL
that displays if you import bridge at all
i tried to think of a nicer way but there kinda wasn't
Ah, looks like I still have it in a test file
Well, since I don't use Option in a bridge context, I'll ignore it.
Thanks for the answer!
bin dauer raitlimmited
💀
How can i get all members which are banned in a guild
irgend ein teil des codes tut mich limitieren
ohne cogs kriege ich den fehler nicht
also sobald ich allgemein lade hab ich es wieder
import asyncio
import random
import discord
from discord.ext import commands
from discord import slash_command
from discord.ext.commands import bot
from discord.commands import Option, OptionChoice
from discord import ui
class allgemein(commands.Cog):
def __init__(self, bot):
self.bot = bot
@slash_command(name="gutenmorgen",description="Wünscht allen Usern einen Guten Morgen")
async def gutenmorgen(self, ctx):
embed_gm = discord.Embed(title="Einen wunderschönen guten Morgen.",description=f"der User {ctx.author.mention} wünscht euch einen Tollen Start in den Tag",color=0x00ff00)
embed_gm.set_footer(text=f'Gesendet von: {ctx.author.name} • {ctx.author.id}', icon_url=ctx.author.avatar_url)
await ctx.respond(embed=embed_gm)
@slash_command(name="gutenacht",description="Wünscht allen Usern eine Gute nacht")
async def gutenacht(self, ctx):
embed_gn = discord.Embed(title="Gute Nacht.",description=f"der User {ctx.author.mention} wünscht euch eine gute Nacht",color=0x00ff00)
embed_gn.set_footer(text=f'Gesendet von: {ctx.author.name} • {ctx.author.id}', icon_url=ctx.author.avatar_url)
await ctx.respond(embed=embed_gn)
@slash_command(name="hallo",description="Sage Hallo")
async def hello(self, ctx):
gifs = ['https://cdn.discordapp.com/attachments/102817255661772800/219512763607678976/large_1.gif',
'https://cdn.discordapp.com/attachments/102817255661772800/219512898563735552/large.gif',
'https://cdn.discordapp.com/attachments/102817255661772800/219518948251664384/WgQWD.gif',
'https://cdn.discordapp.com/attachments/102817255661772800/219518717426532352/tumblr_lnttzfSUM41qgcvsy.gif',
'https://cdn.discordapp.com/attachments/102817255661772800/219519191290478592/tumblr_mf76erIF6s1qj96p1o1_500.gif',
'https://cdn.discordapp.com/attachments/102817255661772800/219519729604231168/giphy_3.gif',
'https://cdn.discordapp.com/attachments/102817255661772800/219519737971867649/63953d32c650703cded875ac601e765778ce90d0_hq.gif',
'https://cdn.discordapp.com/attachments/102817255661772800/219519738781368321/17201a4342e901e5f1bc2a03ad487219c0434c22_hq.gif']
msg = f':wave: {random.choice(gifs)}'
await ctx.respond(msg)
def setup(bot):
bot.add_cog(allgemein(bot)```
aber da ist nichts
Was fegt denn net
ich kriege die ganze zeit limitierungs meldung im log
Zeig
und die slash commands laden net
@vestal folio
04-12-2024-43-02-43 WARNING We are being rate limited. Retrying in 291.10 seconds. Handled under the bucket
Ist in einem cog oder?
wenn ich alle cogs weglasse ist es weg
mach mal @commands.slash_command
die geladen werden
weiß nicht ob das geht
weil ich bissher immer nur @slash_command verwendet hab
probiers
ich hab so was nicht in den pycord docs gesehen
ich nutze immer commands.slash_command
Dann kann man die ganzen imports weg lassen
😄
und blue, bei dir ist es sehr sicher immer noch das problem, dass du zu viele commands an einem tag registriert hast
probiers einfach morgen nochmal
import asyncio
import random
import discord
from discord.ext import commands
from discord import slash_command, ui
from discord.commands import Option, OptionChoice
Ich havb dir deine imports mal bissle schöner gemacht. Ändere es mal auf das. Du brauchst kein bot importieren
guild.bans()
du kannst Option direkt aus discord importieren
ich mach das wie ich meine
mis sind die imports relativ egal
sollange es klappt
es soll net schöhn aussehen es soll klappen
was?
deine embed imports?
wenn ich murks importiere ja
das wissen wir nocjh nicht
ctx.guild.bans() returns
<discord.iterators.BanIterator object at 0x000001FBAF58C640>
konnte es ja wegen des dämlichen limits nicht testen
docs shows you how to use it
Du importest so viel useless stuff
works like other iterators such as channel.history, reaction.users etc
das was ich brauche
wobei ich auch einiges jezt wieder entfernt hab
is there a way to do it without limit
weil ich es nicht mehr brauche
(that doesn't exist, but the rest of the imports are fine)
set limit=None
da hatte ich was probiert
YESSS THANKS xD
Okay
und vergessen zu entfernen
schreib die / commands mal auf einen guild
wie meinst du?
debug_guilds=[ServerID]
wo du den bot in der main definierst
hab ich bereits
Und?
Blöde frage aber hast du discord maybe reloaded? Kann sein, dass die net direkt angezeigt werden
just make them global to bypass the limit then
global commands and guild commands have separate ratelimits
guild have not that hard?
it's the same 200, but they're individual
Okayyy
https://discord.com/developers/docs/interactions/application-commands#registering-a-command
There is a global rate limit of 200 application command creates per day, per guild
ja hab ich
hilft net
dann mach das mal raus
was?
die debug guilds
ok
moment
muss es suchen
was weiß ich wo ich das hingepackt hate in den untiefen vom code
ganz unten
na klar
Das kannst du absolut ohne testen..
das kannst du sogar ganz ohne internet testen
... Time..
