#Basic Pycord Help
1 messages · Page 34 of 1
well ye basically iframe
and pypresence supports the Discord authentication part
https://github.com/discord/embedded-app-sdk here, have fun
ts = python i agree
you only need the sdk if you are interacting with discord (which you may or may not need)
I have yet to hear of native python support in browser engines
there are libraries
ts = 🤮
-> any
Bleh, just curious, does ApplicationContext have a method to respond with a response type 10? aka premium button
like to bring up the premium subscribe modal?
Yeah, the response with a button to subscribe
It's only for apps with monetization, but pycord supports entitlements and that, so...
not sure, i dont think so
Hi, is it possible to use automod via Pycord ? (to obtain this badge)
yes
how i can make an option in a command that has only the staff in my server?
thanks i will take a look
What on Earth is that badge?
When you complete a Discord quest, they give you that badge
I streamed a game for 15 mins to obtain it
I'm so confused
This one is for bots using discord automod
I mean I didn't know about that one either
sorry
The second one?
yes the robot one
Got a link for that one?
maybe
I'll check
Yes right here https://support-dev.discord.com/hc/fr/articles/13847462843543-Introducing-the-AutoMod-Badge
You may have noticed a new badge floating around on various bot profile pages. Here is some info about the AutoMod badge and how to obtain it for your application:
💡 If your app has at least 100 ru...
what sql system i should use sqlite3 , aiosqlite or something else?
for sqlite you should use aiosqlite
there diffs in them?
one is asyncio one is not
if i use sqlite3 its really matter to change or i can just do thing with aiosqlite from now?
ok
Using async lib I often get the error task pending destroyed, do you have an idea ?
Is that really better to use a asynchronous db than a def of it doesn’t change that lunch thing
I dont use aiosqlite for my DB
what you use?
pymongo with motor (MongoDB) which is a NOSQL DB
is it possible to make the bot use a command?
Bots can't run other bots slash commands.
and there own commands?
copy the code?
or make a helper function and call that in both commands, or whatever
you have the entirety of python to work with
hey for some reason I keep getting this error: AttributeError: 'NoneType' object has no attribute 'edit'
from the following function:```py
@tasks.loop(seconds=10)
async def updateEmbedMessage(self):
if(self.configManager.getMessageId() == ""):
print("No Embed Message")
return
message: Message = self.configManager.getMessagebyId(self.bot, self.configManager.getMessageId())
values = self.getEmbedData()
statusEmbed = StatusEmbed.getEmbed(
serverName= values["serverName"],
playerOnline= values["players"],
maxPlayer= values["maxPlayers"],
latency= values["latency"],
iconLink= values["iconLink"],
statusColor= discord.Color.green()
)
await message.edit(embed=statusEmbed)
print("Update Embed")
I dont know how to fix this right now.
but why
thats for you to find out
It should get the message from my configManager.
whatever your message getting function is, it doesnt work properly
yea, well, it doesnt lol
It's not really related to Pycord but i would need help, im using requests and when i pass the proxies in the parameters it doesn't use them and it returns my IP
How can i fix that?
how i can check if a user has the permission to manage_channels?
@discord.has_permissions(manage_channels=True)
or you use the @discord.default_permissions(manage_channels=True) decorator to hide the command from them entirely which is usually better
that is indeed not pycord related at all
and you should never use requests
Hey back again with another problem. For some reason the ```py
message: Message = self.bot.get_message(self.configManager.getMessageId())
Wont give me the message. But the getMessageId works.
the message isnt cached
?
can you give me an example. I dont understand how to use it.
This is what I have right now:
message: Message = utils.get_or_fetch(channel, 'message', self.configManager.getMessageId())
of course not. It wasn't awaited
right
it says channel not defined so I tried it with the dicord.TextChannel. There I get the error discord.TextChannel has no attribute 'get_message'.. And I tried it with await still doesent work
So I need to save the channel id too?
well, yes
I don't think get_or_fetch is applicable here
no?
since messages aren't cached with channel objects

probably just message = get() or await fetch(), although you need to handle the error in case the message is deleted or something
can you give me an example or send me a documentation page?
what do you not understand?
how does get() work?
yea
thats why I asked
The main problem is that I dont have Context. I run this in a Task.loop
i still think get or fetch should work but squid says it doesnt so idk
@shell radish Do you have any Idears?
cna you still try get_or_fetch, and pass the channel you get via bot.get_channel
because the channel should be cached
I try that.
squid might be right tho
When I am trying to add a slash command inside a cog i get an error saying Bot has no attribute 'add_command'
why are you using that?
I need the slash command to be able to access a member variable in the cog
you dont use add_command
you just use the decorator
invoke is not better ?
what bug
I can't remember hold on
not aware of any noticable bug with 2.5 rn
also, think about using database
json are not that good
...
just open the github repo
you will see a lot of them
yeah thought about that was just trying to do a quick and dirty but should use a small db
im not aware != there is none
well, did it work before?
like the fact that the / commands are just broken
what I am doing now is new
no, they just arent lol
has nothing to do with other bug
do you use bot.add_command anywhere manually
no
yes they are a few big issue with it
literally zero issue on 3 slash only bots on 2.5

but yes is true that the slash commands doesnt unload when a cog is unloaded is not a bug
what exactly did you change since it worked
can you show me ur bot definition pls ?
you should use bot = commands.Bot and not discord.Bot or discord.Client
discord.Bot is slash only i think
Changing to commands.bot let it run at least
discord.Client # just for events
discord.Bot # events + slash/user/msg commands
commands.Bot # above + prefixed commands
bridge.Bot # above + bridge commands (application commands and text commands in one)
so you should have bot = commands.Bot(command_prefix="yourprefix")
none of my commands are available but it doesnt error
I just want slash commands tho
you are using prefix commands
i dont care about the prefix
so do not use command.command
that's for prefix commands
.rtfm slash_commands
if yo uwant slash commands use discord.Bot and discord.slash_command
why it never work with me
.rtfm slash
discord.SlashCommand
discord.SlashCommand.after_invoke
discord.SlashCommand.before_invoke
discord.SlashCommand.call_after_hooks
discord.SlashCommand.call_before_hooks
discord.SlashCommand.callback
discord.SlashCommand.can_run
discord.SlashCommand.cog
discord.SlashCommand.cooldown
discord.SlashCommand.copy
discord.SlashCommand.dispatch_error
discord.SlashCommand.error
discord.SlashCommand.full_parent_name
discord.SlashCommand.get_cooldown_retry_after
discord.SlashCommand.has_error_handler
discord.SlashCommand.invoke
discord.SlashCommand.invoke_autocomplete_callback
discord.SlashCommand.is_on_cooldown
discord.SlashCommand.is_subcommand
discord.SlashCommand.mention
here
wonder if rtfm means read the fucking manual
moght be
get() or fetch() will work, but not get_or_fetch()
Why the hell get_or_fetch requires a channel?
?
if you want to get or fetch a message i guess
because how else are you supposed to access a message?
it doesn't work because channel doesn't have any message-related attrs that g_or_f accepts
Does pycord support the discord store purchases?
Like being able to detect if a purchase has gone through
no
is there a plan to do so?
Oh, lol, fetch is a method from a channel not the bot. Yeah.
pretty sure it's not gateway so we can't
oh
actually, it seems like it is gateway so you should open a github issue as a feature request
isn't that what SKUs are?
thought it was related to an SDK or oauth or something
in what order does discord.Interaction callback is called?
I have multiple discord.Interaction callback in View and Modal subclasses. but it seems like on_interaction listener is called first.
is there a way to prioritize active View or Modal callback over commands.Cog listener? or maybe to ignore it?
there's no specific order in which they're executed, they're just scheduled and run concurrently when it recieves the event
You can still overwrite it if you want to ignore that, but be sure to know what u do or everything will be broke
I have a clear objective on each interaction but for some reason Modal and View callback is ignored when there's on_interaction listener in the Cog
Why did you add the on interaction listener
Because with that listener it then ignore the callback because the callback is handle in the on interaction I guess
because the interaction callback in View's interaction_check didnt get called for some reason
Can you show me ur code ?
sure, give me a moment
class EditorView(View):
def __init__(
self,
name: str,
message: discord.Message = None,
):
super().__init__(timeout=None)
self.name = name
self.ticket_message = None
if message is not None:
self.ticket_message = message
# just to add Buttons/Selects
self.setup_items()
else:
raise AttributeError("message cannot be None")
async def interaction_check(self, interaction: discord.Interaction):
modal = EditorModal(self.ctx, self.name, message=self.ticket_message)
match interaction.custom_id:
case "add_select":
modal.add_select()
await interaction.response.send_modal(modal)
case "add_option":
modal.add_field()
await interaction.response.send_modal(modal)
case "edit_embed":
modal.edit_embed()
await interaction.response.send_modal(modal)
return True
class EditorModal(Modal):
def __init__(
self,
ctx: discord.ApplicationContext,
name: str,
message: discord.Message = None,
):
super().__init__(title="Ticket Editor")
self.ctx = ctx
self.name = name
self.action = None
if message is not None:
self.message = message
else:
raise AttributeError("Message cannot be empty")
async def callback(self, interaction: discord.Interaction):
match self.action:
case "add_select":
await self.callback_select(interaction)
case "edit_embed":
await self.callback_embed(interaction)
case "add_field":
await self.callback_field(interaction)
case None:
await interaction.response.send_message("Unknown Interaction")
self.stop()
Where is the setup items -
Because the setup items is the one that receive the callback
For the interaction check can be triggered
Setup items is just bunch of add items tbh
def setup_items(self):
self.add_item(
Button(
label="Add Select",
custom_id="editor-select-add",
style=discord.ButtonStyle.green,
)
)
self.add_item(
Button(
label="Edit Title/Description",
custom_id="editor-embed-edit",
style=discord.ButtonStyle.green,
)
)
self.add_item(
Button(
label="Add Field",
custom_id="editor-field-add",
style=discord.ButtonStyle.green,
)
)
self.add_item(
Select(
placeholder="Select Field to Remove",
custom_id="editor-field-remove",
options=(
[
SelectOption(label=field.name, value=field.name)
for field in self.ticket_message.embeds[0].fields
]
if len(self.ticket_message.embeds[0].fields) > 0
else [SelectOption(label="No Fields", value="No Fields")]
),
)
)
view = View.from_message(self.ticket_message, timeout=None)
self.add_item(
Select(
placeholder="Selection to Remove",
custom_id="editor-select-remove",
options=(
[
SelectOption(
label=", ".join(
[option.label for option in select.options]
),
value=select.custom_id,
)
for select in filter(
lambda item: isinstance(item, Select), view.children
)
]
if len(list(filter(lambda item: isinstance(item, Select), view.children))) > 0
else [SelectOption(label="No Selects", value="No Selects")]
),
)
)
Here is ur issue
You add the items but you don’t put any callback
You need to pass the callback
You can do button = …
Button.callback =
Self.add item (button)
And then you can remove ur listener
the bulk of the callback is in Modal subclass, didnt include it since it's too long to fit in a single message
every callback is based on the component's custom id and I just used match case to determine which function to call with the given id
also idk that it's possible to set a callback with Button.callback
How did you set the callback so ?
subclassing Modal
async def callback(self, interaction: discord.Interaction):
logger.info("[EditorModal] Interaction with ID: %s", interaction.custom_id)
match self.action:
case "modal-select-add":
await self.callback_select(interaction)
case "modal-embed-edit":
await self.callback_embed(interaction)
case "modal-field-add":
await self.callback_field(interaction)
case None:
await interaction.response.send_message("Unknown Interaction")
self.stop()
async def callback_select(self, interaction: discord.Interaction):
view = View.from_message(self.message, timeout=None)
self.item = Select(
placeholder=self.children[0].value, custom_id=f"ticket-{self.name}-options"
)
options = re.split(r"[,\n]", self.children[1].value)
for option in options:
self.item.add_option(label=option, value=option)
k = re.split("\W+", option)[0].lower()
config.update(f"tickets.{self.name}.options.{k}", option)
save_config()
view.add_item(self.item)
view.add_item(TicketButton(self.name))
await self.message.edit(view=view, embeds=self.message.embeds)
await interaction.response.send_message("Select options added!", ephemeral=True)
self.stop()
async def callback_embed(self, interaction: discord.Interaction):
title = self.children[0].value
description = self.children[1].value
config.update(f"tickets.{self.name}.title", title)
config.update(f"tickets.{self.name}.description", description)
save_config()
if len(self.message.embeds) > 0:
self.message.embeds[0].title = title
self.message.embeds[0].description = description
else:
self.message.embeds = [discord.Embed(title=title, description=description)]
self.message = await self.message.edit(embeds=self.message.embeds)
await interaction.response.send_message("Embed updated!", ephemeral=True)
self.stop()
I changed almost all custom ids to make it easier just now
I don’t see anything about call back for the button here
Whatever, I think you should redo it using the button.callback method
It will be better for you and for the future
Do you want to see an example of how it looks ?
not really, I already have something in mind as to how to do it
thanks for confirming that Cog's listener overrides everything on subclasses though
As you want
But you might just do something really hard for nothing
totally can see myself having that 
well it's more fun that way
thanks again btw. really helps
Does anyone know where that error could be coming from ?
It is happening randomly, and making the bot crash completely
do you have bad net?
yeah sometime it disconnect, but I handle it in on_disconnect
but in that case, the bot crashes completely, it does not even fire the events for reconnection
Here's the exact commit in case you don't want to use the latest
what version of python does latest version of py-cord support
3.12
Is it normal for my sharded bot to fire on_ready() some time after launch? I have some tasks that start there and I get errors for the bot trying to start those tasks again in on_ready() while they're running.
Is it okay to let that happen or should I add a flag to prevent it?
I already made it check if the tasks are running before trying to launch them so the errors are gone.
ah, yea, then its okay
Although I don't want it to reset my database connections and HTTP clients so I'll probably just prevent executing it more than once.
You should use on shard ready I think
In version 1.5 comes the introduction of Intents. This is a radical change in how bots are written. An intent basically allows a bot to subscribe to specific buckets of events. The events that corr...
Thanks!
how to catch 400 bad request missing permission (the bot) in on_command_error event? I'm using commands.BotMissingPermissions but not catched
Even if I initialize all my API clients and database connections in the ready function? Wouldn't it just reset them with each shard?
Maybe initialize them in the on_shard_readt
But I’m not sure about that
Maybe someone her can correct me if I’m wrong
what are you doing that causes that error
edit role position to be higher than author top role position
Yeah but from my understanding on_shard_ready() fires with each shard so it would initialize them several times.
check if the bots highest role is higher than that, and if not, return
dont wait for the error to happen to handle it :>
Yes that’s possible
Is it possible to assign a user a role while a bot is starting up but hasn't reached on_ready() yet? Can I run a separate instance until the initial bot has reached the on_ready()? Using AutoShardedBot
I'm assuming event listeners such as on_guild_join() aren't triggered until the bot is ready as well?
it is triggered, ready only means cache was loaded. it's operational much earlier.
brings up a question i never thought about. what would happen if their highest roles are equal and both have permissions to edit roles?
(context; meaning both, the bot and the member were assigned a self made role that's higher than the bots role)
assuming we did an equal or higher check of course!
I don’t have an equal, just a greater than check
that equal to question was meant for toothy and more of a curiosity thing, not any usecase i have seen here. the usecases at hand just made me wonder about it.
I tried adding information such as guild ID to a database in this listener but it only works after the bot is ready
depends on how you want to handle it. there is two possible ways that can make sense.
have an "is_ready" check in your on guild join check and return when it is not OR wait until ready and then handle it.
maybe you could also try to fetch the members information if you can't get it, which would ad it to cache. didnt try this last one.
all have their up and downsides obviously
I tried with and without the is ready check and both aren’t what I’m looking for. Will waiting execute the function for all the instances that were triggered when the bot is finally ready?
If equal : missing permission raise
not possible
i mean it should be possible to, for example, kick someone with an equally high role, if the bot has kick permissions and the member does not have admin.
interesting that it's not doable for role manipulation, wasn't aware! : D
that would be absolutely catastrophic
never thought about it before, had no need to
that would mean any mods in any server could kick every other mod
I stated if one has the permission to kick and the other does not
Something that's doable with a teamspeak-like permission system though :3
hahahaha 😄
Yeah, you're right, does sound catastrophic! 😄
guess we just found sth. discord does better
better than teamspeak? hell no
the kick szenario i meant.
but safer, considering all the nuts that claim to "own" servers, yet have not a clue about anything beyond creating channels
yea
I think that's better. kicks and bans should be allowed with some safety in mind.
how do i get the user id of the user who presses the button?
its at the docs
i was thinking something like that but wasn't sure
Should I make a #969574202413838426 post for this?
The docs dont bite
Yes, probably
are you sure about that?
Ask Fabio, he read all the docs from top to bottom
@frail ocean did the docs bite you?
Lmfao the actual ping and question kills me
oh yes
no
@sage tendon react
How many do we need? 2? 3?
Im not gonna say how many you need for it xd
@lofty parcel #starboard message 
hello!
def some_func(id=message_id):
guild = bot.get_guild(guild_id)
channel = guild.get_channel(channel_id)
bot.loop.create_task(some_other_func(channel, id))
any idea why this keep returning none for the guild ? my id is correct i double checked
guild = bot.get_guild(guild_id)
where does 'guild_id' come from? it's not in your parameters
Duuuude 😮
Don't do that, on a global scale only use constants if anything.
I will clean up my code later, i am just trying to see if i can execute functions without using the bot
basically, i would like to execute actions with a bot using fetches without using a webhook
can't find infos about this in the docs
with only the message, asssuming it is type discord.Message, available you can:
message.author.guild.id
IF you have the members intend in your bot.
else you may try guild_id instead, idk if that's availible within this context though.
this should deliver the guild id if your bots cache is loaded and you have the needed intents
that is not meant to be a message interaction, will it still work ?
i mean, would I be able to execute my function in python (so use it along with a fetch afterwards?)
oh right. you only have a message id
guild is predefined as well as the channel
before we start over complicating things, give some context please. why does this function only have this id available? and can you give it something more useful like the message object itself or ctx or.. any other sensible starting point?
what i am trying to do is recreate this slash command in ways that could be used without direct interactions with the bot
@bot.slash_command()
async def hi(ctx, message_id=int(message_id)):
channel =bot.get_channel(int(channel_id))
message = await channel.fetch_message(message_id)
out = message.attachments[0].url
await ctx.respond(out)
(get first attachment url by message id)
I'm so confused about that
def get_img_by_id(id=message_id):
image_url = ''
guild = bot.get_guild(guild_id)
channel = guild.get_channel(channel_id)
bot.loop.create_task(retrieve_image(channel, id))
async def retrieve_image(channel, id=message_id):
await bot.wait_until_ready()
await channel.send('Uploading...')
# message = channel.fetch_message(id)
# image_url = message.attachments[0].url.split("/")[5]
# return image_url
would result into something like this..
why not use ctx? everything you'll need is in there
can i use ctx without bot interaction ?
No
you cant do any slash command without bot interaction at all
what i am trying to do is retrieve images so ctx wont work for me then
I might be a bit dumb rn but what even is the point of this, especially without ever interacting with the bot
to address the issue of discord new image urls
I fail to see how getting some pic would make bot interactions unusable
there is no more permanent urls for hosted images through discord but message id is still permanent
if i store a pic through discord i cant retrieve it after approx one week
but if i get this url through message id, it would be the latest url so it will work
I think I am starting to understand
did you try fetching the message with the picture instead of getting it?
wdym by fetching the message ? what would be the difference ?
get uses your bots cache. old messages are not in cache. fetching means to send an api request for [insert what ever you want to get here].
would be perfect but i read on internet that i can't use api for such purposes as it requires the bot for auth
maybe i'm wrong
it's recommended to go easy on fetch operations, cause each one will send an api request and therefore may lead to reaching a limitation if you overdo it. However if you need an object, regardless if its a member or a message and get returns None you try fetch next.
Keep in mind that fetch can still fail, when the message was deleted or the bot is not allowed to see history or was removed from a server or some such thing. in those cases the message you're trying to fetch will still be None.
i really don't know what to do, let me give an example
here is an image that i just uploaded
https://media.discordapp.net/attachments/1132206148309749830/1233727789299929098/image.png
before this was enough to retrieve it
but now, if you try to open this url it wont work, it will give an error like "This content is no longer available."
so if you want to get the file (eg. by opening in browser) there is some kind of secret added to the url which renews each week
https://cdn.discordapp.com/attachments/1132206148309749830/1233727789299929098/image.png?ex=662e260a&is=662cd48a&hm=db7ae0051a25f9f7406479574517967c5f1e34786a239d8eabfdbca1996b8abc&
so i can access this url like this but next week it will no longer be working, i just need to figure out how can i get my images to work again
one day* most recently
..and you are programming a discord bot
i'll just look for some other ways to host my images
Try fetch guild
I think I saw something about that now it’s only 24h
it sucks
.
i was hosting images through discord since almost 2 years now
and, i am using them for my summary notes and stuff (for class)
For outside discord? yeah, that's just not what discord is for, and exactly what they're trying to prevent now
now all users lost their pfp and all the posts no longer have their images
i don't even know where should i move my stuff now
i am hosting my website through free services (as well as the db) and it wont be enough to start hosting images, especially since there is no rates about how uch images can be uploaded
any idea of a free permanent alternative ?
not for free
replit woudl've been a great alternative if they had not shut down their free hosting service (10GB disk for free)
So basically you are a freeloader and somehow think the world ows you cloud storage. Now you are disappointed because Discord doesn't allow you to abuse their platform as a free-unlimited cloud service anymore?
Aaand because that's not working as intended you are asking for help here.
Oh the entitlement, attitude and nerve.
All you'll get from me is piss off, I am out
come now, toothy, how much is a ten GB plan? we can get virtual machines with like 30 for just shy of 3$ if its only for storage. must be a fraction of that, not a reason to steal in my book.
wasnt commenting on that
i am not exactly sure how to read this emoji
"damn didnt expect that harsh response suddenly"
me neither, just hit a nerve there.
👋
How is is that I send a message to a specific channel?
I'm currently trying:
info = self.get_channel()
await info.message.send("Astral Dynamics Assistant is ready!")
But this is giving me a TextChannel object has no attribute message error.
I've used ctx.respond/send etc.. but this message doesn't have a ctx to respond too 😄
yea, discord.TextChannel doesnt have .message :)
it's just .send
.rtfm TextChannel
discord.TextChannel.permissions_for
discord.TextChannel.permissions_synced
discord.TextChannel.pins
discord.TextChannel.position
discord.TextChannel.purge
discord.TextChannel.send
discord.TextChannel.set_permissions
discord.TextChannel.slowmode_delay
discord.TextChannel.threads
discord.TextChannel.topic
discord.TextChannel.trigger_typing
discord.TextChannel.type
discord.TextChannel.typing
discord.TextChannel.webhooks
discord.ext.commands.TextChannelConverter
discord.ext.commands.TextChannelConverter.convert
note that it was meant for personal usage only and I am just trying to retrieve my old uploaded images using their ids to move to some other service. i am obviously not serving images by getting a message data through a bot each time it needs to load.
i still dont get why you do it this complicated
OneNote??
i made my own tool adapted to my personal usage, that's the reason
it is basically markdown with extended support (supports all of discord functionnalities, twemojis, multiple themes, custom textboxes, ability to insert images from web quickly, ability to create multiple choice questions, LaTeX...) w/ live preview
how i can handle
discord.ext.commands.errors.MissingPermissions
check if you have permissions before doing what you're doing
i am doing this:
# auto craetes logs
@commands.slash_command(name="auto-setup-logs", description="setup every thing for you that related to logs")
@commands.has_permissions(manage_channels = True)
@commands.cooldown(1, 10)
async def setup_logs(self, ctx, staff_role: discord.Role):
try:
#the rest of the code:
except (discord.ext.commands.errors.MissingPermissions) as e:
ctx.response.send_message("You dont have permission to do this!", ephemeral=True)
again, check permissions before trying to do whatever you're doing in the try
there's no need to wait for it to error, make sure it can't happen
and i'd use @discord.default_permissions for slash commands
how i can check before he even doing the commnad?
you can also use has_permissions
its fine but the permission cannot get changed for it
has permissions wont hide the command from the user for all i know
that is right
Check in the code
what are you doing
🤔 I just added a command to my bot. Restarted it, but now it doesn't have the new commands on the server?
restart discord
@deft kestrel you also should start to use an Error Handler for your commands so you dont need all the try and except at your code
# auto craetes logs
@commands.slash_command(name="auto-setup-logs", description="setup every thing for you that related to logs")
@commands.has_permissions(manage_channels = True)
@commands.cooldown(1, 10)
async def setup_logs(self, ctx, staff_role: discord.Role):
if (ctx.user.has_permissions(manage_channels = True)):
like that?
creating every channel i need for the logs
add it db and thats it
Then check if your bot has permissions to create a channel
if not, return
Use a discord message as a JSON file to store data!
wtf no
I tried it once.. it was terrible
no i mean that when somebody edits message it will send it in a channel
i mean if the user that do the command has the permissions
That's not the error you're getting
you get that error because your BOT cant create the channels
he can create in my account i can
but on my alt i cant because in my alt he doesnt have the permissions
or wait no
Yea, well, again
use @discord.default_permissions
i told you this a while ago, too
and 5m ago too
has_permissions should not be used
If i read your code correctly the error is caused because of the @permission decorator. It stops the command from executing if the user does not have the needed permissions and therefore raises an error instead of doing its job.
there is several ways how you can resolve it
a) remove the decorator, control access through server settings
b) have your own permission check that checks what permissions the command user has, return if the wanted ones are not among them (or send a response and return/end the command afterwards)
c) leave as is and build an error handler
ping
:3
did the @discord.default_permissions
why is player still not defined
probably because whatever you're doing is not right at all
what is [Players] supposed to be
you can either have a string or a single member as input type (among a few others, and I suppose you pass these 1:1 from a slash command option)
your IDE even tells you it's not correct by the squiggly line under it
and I'm not sure you understand what a classmethod is
remove that decorator
If you want to typehint a list of something, you need to use list[type]
damn
I mean, read the error and read your code
your auto responder is also missing a setup function
😂
im doing a tetris game rn
good luck with that
if you want look #creations can still help for the visual
How the fuck you make a tetris game on discord
mfw you need 50 edits just for one piece to drop
you will see today i guess
i will do like my snake game
cant fix this sht damn it
Unhandled exception in internal background task 'checkGames'.
Traceback (most recent call last):
File "C:\Users\lenov\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\tasks\__init__.py", line 169, in _loop
await self.coro(*args, **kwargs)
File "c:\Users\lenov\Desktop\cogs\cogs\gewinnt.py", line 98, in checkGames
games = await Connect4.getAll(self.pool)
File "c:\Users\lenov\Desktop\cogs\cogs\gewinnt.py", line 220, in getAll
async with self.pool.acquire() as conn:
AttributeError: 'Pool' object has no attribute 'pool'
but with tetris
definining pool in your class
Autocorrect
I don't think my brain is smart enough to think about the logic
so import the pool in ur file
from main import ...
like its just a loop
but how 
I've seen you here like 10 times now with the exact same issue but it's always ever so slightly different
😅
from main import ...
I won't download the file. But assuming it's in your main file because its a bot attribute
and the ... should be ur database
Can't you just self.bot.pool
i hate my life, cant even fix this god damn error
@sly ember did u try that ?
Unhandled exception in internal background task 'checkGames'.
Traceback (most recent call last):
File "C:\Users\lenov\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\tasks\__init__.py", line 169, in _loop
await self.coro(*args, **kwargs)
File "c:\Users\lenov\Desktop\cogs\cogs\gewinnt.py", line 98, in checkGames
games = await Connect4.getAll(self.pool)
File "c:\Users\lenov\Desktop\cogs\cogs\gewinnt.py", line 220, in getAll
async with self.bot.pool.acquire() as conn:
AttributeError: 'Pool' object has no attribute 'bot'
your getAll is a static method, static methods do not take a self argument
So
games = await Connect4.getAll(self.pool)
...
@staticmethod
async def getAll(self):
async with self.pool.acquire() as conn:
So self is treated as a normal positional argument so essentially you are doing
self.pool.pool.acquire
as in getAll self = self.pool
You could fix it by changing self to pool and not doing self.pool
but what should i do there
Unhandled exception in internal background task 'checkGames'.
Traceback (most recent call last):
File "C:\Users\lenov\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\tasks\__init__.py", line 169, in _loop
await self.coro(*args, **kwargs)
File "c:\Users\lenov\Desktop\cogs\cogs\gewinnt.py", line 98, in checkGames
games = await Connect4.getAll(self.pool)
AttributeError: 'Connect4Game' object has no attribute 'pool'
pool = pool
bruh
will actually do anything*
If they used an actual IDE it would've showed that as well
i use vscode
why ?
in my eyes
what exactly do you think var = var achieves?
self.pool = pool
to then in the command
yea
be able to use pool
huh
so why self.pool = pool is useless ?
that's not what I said
I meant do the changes to the getAll function
how i can send a message with the bot
but the message is: using `````` ```
escape them with \
i have a problem with pycord is the import from slash_command not ```from discort import slash_command````??
i have this
Traceback (most recent call last):
File "/home/container/main.py", line 9, in <module>
from discord import slash_command
ImportError: cannot import name 'slash_command' from 'discord' (/home/container/.local/lib/python3.10/site-packages/discord/__init__.py)```
pycord version?
newest
no discord.py installed?
i have in the requirements.txt py-cord
yes
try from discord.commands import slash_command
which exact version
saying newest is cool but doesnt have to be correct :>
i have the problem one
now is that
Traceback (most recent call last):
File "/home/container/.local/lib/python3.12/site-packages/discord/ext/commands/bot.py", line 935, 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 "/home/container/cogs/moderation.py", line 9, in <module>
from discord.commands import slash_commands, Option
File "/home/container/.local/lib/python3.12/site-packages/discord/commands/__init__.py", line 26, in <module>
from .context import *
File "/home/container/.local/lib/python3.12/site-packages/discord/commands/context.py", line 69, in <module>
class ApplicationContext(discord.abc.Messageable):
File "/home/container/.local/lib/python3.12/site-packages/discord/commands/context.py", line 271, in ApplicationContext
@discord.utils.copy_doc(Interaction.respond)
^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'Interaction' has no attribute 'respond'. Did you mean: 'response'?
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/container/main.py", line 46, in <module>
bot.run(token)
File "/home/container/.local/lib/python3.12/site-packages/ezcord/bot.py", line 888, in run
super().run(token, **kwargs)
File "/home/container/.local/lib/python3.12/site-packages/discord/client.py", line 860, in run
asyncio.run(runner())
File "/usr/local/lib/python3.12/asyncio/runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/home/container/.local/lib/python3.12/site-packages/discord/client.py", line 849, in runner
await self.start(token, reconnect=reconnect)
File "/home/container/.local/lib/python3.12/site-packages/ezcord/bot.py", line 914, in start
await super().start(token, **kwargs)
File "/home/container/.local/lib/python3.12/site-packages/discord/client.py", line 777, in start
await self.login(token)
File "/home/container/.local/lib/python3.12/site-packages/discord/client.py", line 621, in login
await self.setup_hook()
File "/home/container/.local/lib/python3.12/site-packages/ezcord/bot.py", line 833, in setup_hook
await self.load_extension(cog)
File "/home/container/.local/lib/python3.12/site-packages/discord/ext/commands/bot.py", line 1013, in load_extension
await self._load_from_module_spec(spec, name)
File "/home/container/.local/lib/python3.12/site-packages/discord/ext/commands/bot.py", line 938, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.moderation' raised an error: AttributeError: type object 'Interaction' has no attribute 'respond'```
this said python 3.10, your new error says python 3.12
what is your python setup lmfao
i have python 3.12
that is most likely why
no, its not a bug, its the reason why it doesnt work (most likely)
show the code that caused that
i have vby server create python 3.12 selectet

ok the directory .local is the problem i have that deleted
File "/home/container/cogs/moderation.py", line 9, in <module>
from discord.commands import slash_commands, Option
ImportError: cannot import name 'slash_commands' from 'discord.commands' (/home/container/.local/lib/python3.12/site-packages/discord/commands/__init__.py). Did you mean: 'slash_command'?
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/container/main.py", line 45, in <module>
bot.load_cogs(subdirectories=True)
File "/home/container/.local/lib/python3.12/site-packages/ezcord/bot.py", line 318, in load_cogs
self.load_extension(cog)
File "/home/container/.local/lib/python3.12/site-packages/discord/cog.py", line 912, in load_extension
self._load_from_module_spec(spec, name)
File "/home/container/.local/lib/python3.12/site-packages/discord/cog.py", line 781, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'cogs.moderation' raised an error: ImportError: cannot import name 'slash_commands' from 'discord.commands' (/home/container/.local/lib/python3.12/site-packages/discord/commands/__init__.py)```
requirements
ezcord
py-cord
I wonder how you got the stuff installed and how you run it
Remove ezcord
ezcord should be fine
Don't use some shitty extension
lul
it quite literally tells you and even suggests the right thing
thats why the order is this
- read error ENTIRELY
- send error here
and not just step 2 :3
ah i see, how can i fix this one?
read
many dont like it to read
thats why i make em
or people cant read
you were already told to remove the staticmethod decorator from that function
why do you not do that
again, read this


i mean, dont laugh, fix it
i cant 😢
it tells you exactly what's wrong
your self is Connect4Game
it does not have an acquire function
i have a problem i made a file that his name is functions
and i added to the file this:
# Defining sub-groups
setup_group = discord.SlashCommandGroup(name = "setup", description="Setup")
messages_group = discord.SlashCommandGroup(name = "message", description = "Log messages")
roles_group = discord.SlashCommandGroup(name = "role", description = "Log roles")
members_group = discord.SlashCommandGroup(name = "member", description = "Log member")
channels_group = discord.SlashCommandGroup(name = "channel", description = "Log channels")
and when i import it to other files its showing me the options to add those kind of groups but when i restart my discord to see them i dont see them
define them in a cog
but then i cant import them
do you need them across multiple cogs?
yes
Please ping me as soon as you remember it
i dont think i will remember it
Lmfao
i was thinking about making this a cog so that the groups are actually added to the bot
but i dont think that works
no it does not have any cog its just defs
Still trying to fix that 
Unhandled exception in internal background task 'checkGames'.
Traceback (most recent call last):
File "C:\Users\lenov\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\tasks\__init__.py", line 169, in _loop
await self.coro(*args, **kwargs)
File "c:\Users\lenov\Desktop\cogs\cogs\gewinnt.py", line 98, in checkGames
games = await Connect4.getAll(self)
File "c:\Users\lenov\Desktop\cogs\cogs\gewinnt.py", line 220, in getAll
async with self.acquire() as conn:
AttributeError: 'Connect4Game' object has no attribute 'acquire'
Unhandled exception in internal background task 'checkGames'.
Traceback (most recent call last):
File "C:\Users\lenov\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\tasks\__init__.py", line 169, in _loop
await self.coro(*args, **kwargs)
File "c:\Users\lenov\Desktop\cogs\cogs\gewinnt.py", line 98, in checkGames
games = await Connect4.getAll(self.pool)
File "c:\Users\lenov\Desktop\cogs\cogs\gewinnt.py", line 224, in getAll
for (guild_id, message_id, players, waiting) in cursor:
TypeError: 'Cursor' object is not iterable
It ain't iterable
Read
You probably want what cursor.execute returns
Read your own code.
That's all I know of SQL
please read your errors, seriously @sly ember
you keep posting your tracebacks here
if you cant read them you cant develop a bot properly
besides, the mysql library has nothing to do with pycord so thats out of scope for here anyway
Figured out my issue. Had some names spelt wrong
you maybe know?
discord.User could be an array? there's something like that? to select more users
thank you
you can solve it by making multiple optional options
any example^
make multiple member options and use required=False
oh ok
how can i create a slash command where one of the parameters has custom options? similar to how you can set the parameter to a channel object and it pops up with channels, i want to be able to make you select from a custom set of options?
like this
Do you mean that when you select a parameter in the slash command its own options are displayed?
I already provided the answer…
I am getting the following whenever I try to use slash commands:
File "/home/user/Documents/discord-bot/hello.py", line 16, in <module>
bot.run(os.getenv('TOKEN')) # run the bot with the token
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/Documents/discord-bot/.venv/lib/python3.12/site-packages/discord/client.py", line 766, in run
return future.result()
^^^^^^^^^^^^^^^
File "/home/user/Documents/discord-bot/.venv/lib/python3.12/site-packages/discord/client.py", line 745, in runner
await self.start(*args, **kwargs)
File "/home/user/Documents/discord-bot/.venv/lib/python3.12/site-packages/discord/client.py", line 709, in start
await self.connect(reconnect=reconnect)
File "/home/user/Documents/discord-bot/.venv/lib/python3.12/site-packages/discord/client.py", line 601, in connect
await self.ws.poll_event()
File "/home/user/Documents/discord-bot/.venv/lib/python3.12/site-packages/discord/gateway.py", line 605, in poll_event
await self.received_message(msg.data)
File "/home/user/Documents/discord-bot/.venv/lib/python3.12/site-packages/discord/gateway.py", line 555, in received_message
func(data)
File "/home/user/Documents/discord-bot/.venv/lib/python3.12/site-packages/discord/state.py", line 818, in parse_interaction_create
interaction = Interaction(data=data, state=self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/Documents/discord-bot/.venv/lib/python3.12/site-packages/discord/interactions.py", line 171, in __init__
self._from_data(data)
File "/home/user/Documents/discord-bot/.venv/lib/python3.12/site-packages/discord/interactions.py", line 201, in _from_data
self._guild = Guild(data=self._guild_data, state=self)
^^^^^
NameError: name 'Guild' is not defined. Did you mean: 'guild'?```
Here is the code I am using:
import os # default module
from dotenv import load_dotenv
load_dotenv() # load all the variables from the env file
bot = discord.Bot()
@bot.event
async def on_ready():
print(f"{bot.user} is ready and online!")
@bot.slash_command(name="hello", description="Say hello to the bot")
async def hello(ctx: discord.ApplicationContext):
await ctx.respond("Hey!")
bot.run(os.getenv('TOKEN')) # run the bot with the token```
which pycord version
just show the pip list pls
Package Version
aiohttp 3.9.5
aiosignal 1.3.1
attrs 23.2.0
Brotli 1.1.0
certifi 2024.2.2
cffi 1.16.0
charset-normalizer 3.3.2
frozenlist 1.4.1
idna 3.7
multidict 6.0.5
mutagen 1.47.0
pip 24.0
py-cord 2.5.0
pycparser 2.22
pycryptodomex 3.20.0
PyNaCl 1.5.0
python-dotenv 1.0.1
requests 2.31.0
urllib3 2.2.1
websockets 12.0
yarl 1.9.4
yt-dlp 2024.4.9
Python 3.12.3
do you use a venv?
Yes
I remember seeing this error before but i think it was with bridge, so I'm not sure why this would cause it
$ ls -l `which python` lrwxrwxrwx 1 user user 15 Apr 28 00:14 /home/user/Documents/discord-bot/.venv/bin/python -> /usr/bin/python
Python 3.12.3```
can you print discord.__version__ in your code
2.5.0```
did you have discord.py installed before by any chance
Nope.
Lemme try a fresh venv
yea i was gonna say try reinstaling pycord, because i dont understand why your code would cause that error at all
Same thing with fresh venv and only pycord + python-dotenv installed
Package Version
------------- -------
aiohttp 3.9.5
aiosignal 1.3.1
attrs 23.2.0
frozenlist 1.4.1
idna 3.7
multidict 6.0.5
pip 24.0
py-cord 2.5.0
python-dotenv 1.0.1
yarl 1.9.4```
I guess I'll try a different interpreter and new venv
Same thing with python 3.9.19 from nix :/
do you have guild.py in venv > lib > site-packages > discord?
If yes then i really dont know, sorry
Maybe the others do, because i have seen this error here before
Same thing in docker with no venv :/
Do you have an example of a working docker container?
$ find .venv -iname guild.py
.venv/lib/python3.12/site-packages/discord/guild.py
.venv/lib/python3.12/site-packages/discord/types/guild.py
yea then I legit don't know
I think this bug is fixed on the master version. Hopefully 2.5.1 will release soon but in the meantime the master branch should be stable enough to use
but what even causes that?
I think it is just a typo in the code
No but, why does it work for like 99% of the rest of the user but not for them
their code is like as simple as it gets
class ConfirmView(discord.ui.View):
def __init__(self, dealid):
super().__init__()
self.dealid = dealid
self.value = None
@discord.ui.button(label="Yes", style=discord.ButtonStyle.success)
async def yes_button(self, button: discord.ui.Button, interaction: discord.Interaction):
self.value = True
print("Yes button clicked")
@discord.ui.button(label="No", style=discord.ButtonStyle.danger)
async def no_button(self, button: discord.ui.Button, interaction: discord.Interaction):
self.value = False
print("No button clicked")
async def interaction_check(self, interaction: discord.Interaction) -> bool:
data = getConfig(self.dealid)
if interaction.user.id == data['reciev']:
return True
else:
await interaction.response.send_message("Only the recipient can interact with this button.", ephemeral=True)
return False
In a different event:
print("Creating confirmation view...")
confirm_view = ConfirmView(dealid)
confirm_message = await message.channel.send(f"Are you sure `{addy}` is the correct LTC address?", view=confirm_view)
print("Confirmation message sent")
confirmation = await confirm_view.wait()
print(f"Confirmation received: {confirmation}")
After clicking either button, the print statements are shown but I get a "This interaction failed" message and there's no error in console.
Also, the confirmation arrives like 3-4 minutes late and I can't find any reason as to why is that
Hope anyone might have an idea
No, it's an on_message event
after the button is clicked, print(f"Confirmation received: {confirmation}") output is sent around 3 minutes late for some reason
in other words, the execution is paused at confirmation = await confirm_view.wait() for a while before it's continued
yea because it waits for the view to time out lol
calling View.stop will make the view stop waiting.
So it will stay on await confirm_view.wait() until the view times out or stop is called
Is there a way to go through all the audit log entries and if a user did this then it continues? And can you get the channel name from channel delete?
what are you trying to do
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 ...
Thx
Why u wanna know
because of https://xyproblem.info/
is it possible to put multiple images to embed set_image??
no
there is a way but it's a little funky
can you say more about it?
if you send multiple embeds with the same URL they'll merge and the images will be added to a single embed
damn thanks
yeah it's a little weird but it exists
psst
oh yea, right
but does that mean the entire embed has to be equal if you want to have text etc?
should be as many embeds as you can add
which I think is 10
Thank you
help:
Exception has occurred: AttributeError
'Bot' object has no attribute 'remove_command'
File "Desktop\bot\testing\bot.py", line 20, in <module>
bot.remove_command("help")
AttributeError: 'Bot' object has no attribute 'remove_command'
i mean, read the last line
what are you trying to do ?
yh but i need to remove it its showing me this:
Ignoring exception in on_connect
Traceback (most recent call last):
File "c:\Users\Assaf Cohen\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 400, in _run_event
await coro(*args, **kwargs)
File "c:\Users\Assaf Cohen\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 1178, in on_connect
await self.sync_commands()
File "c:\Users\Assaf Cohen\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 735, in sync_commands
registered_commands = await self.register_commands(
File "c:\Users\Assaf Cohen\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 599, in register_commands
registered = await register("bulk", data, _log=False)
File "c:\Users\Assaf Cohen\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\http.py", line 373, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In 31: Application command names must be unique
you have 2 commands with the help name ?
i dont have help command at all
its built into pycord
are you using bridge ?
no
show your commands
do help_command = None
in ur bot instance
even if normally /help doesnt exist at all by default
does /help appear on the list of command
you dont even know if the issue is the help command
how?
.
does /help appear on the list of command
because you are trying to remove the help comamnd
check all the name of ur command
luma
to be sure that no one are duplicated
check before discord
cos they will not appear there since it failed to register them
i did
print(bot.all_commands)
{None: <discord.commands.SlashCommand name=feedback-costumer>}
output
One of your commands has the same name as another one
check what you changed since your bot last worked
you cant really do that
try to check in ur code if there is not 2 times the same func
i think maybe i did this:
# ---===GiveAway-commands===---
giveaway_group = discord.SlashCommandGroup(name = "giveaway")
and i have this:
@subcommand(f"setup")
@commands.slash_command(name = "giveaway", description=" the giveaway system")
async def setup_giveaway(self, ctx, role: discord.Role):
subgroup are considered as commands, so you can't have those duplicate
oh ok
why is my bot sending messages in a channel but the channel isn't showing as unread
there it will do /giveaway giveaway
is it the same for everyone else?
i want /setup giveaway and giveaway start etc.
create a group seutp
i have
and then a subgroup giveaway
yeah, but only on desktop
setup_group = discord.SlashCommandGroup(name = "setup", description="Setup")
on mobile it shows up fine
and then you will do
@subcommand(f"setup giveawaty")
@commands.slash_command(name = "start", description=" start the giveaway system")
then its just a discord issue tbh
is there any way to like force discord to reset its cache or smth
restarting discord 
i dont think you got what i wanted to do
i have a group command that his name is setup, I use it to all my setup all my systems
and i want one that his name is giveaway and its like a category in the commands that i could do it for the all giveaway commands i add
like that gary:
setup_group = discord.SlashCommandGroup(name="setup", guild_only=True)
giveaway_setup_group = xp_group.create_subgroup(name="giveaway")
a group name and command name which has the same name should not create an issue
group are like commands so
it will do a duplicate name error
you just cant have
/hello
/hello add
This is ok tho
/hello add
/test add
it was about /setup setup
which is not possible
I dont get any errors from it, its just not registering for me
if its not registering its an error no ?
i think
good thing that u think
perfect
how do i have my /echo command not ping the role or anything
?
Some classes are just there to be data containers, this lists them. Unlike models you are allowed to create most of these yourself, even if they can also be used to hold attributes. Nearly all clas...
yea im looking for where i used it in my code, 1s
here, thats how i used it
but if you want no mentions at all you can use discord.AllowedMentions.none()
so where could i add it here?
after the content in your send
like this?
Alright thanks so so much
this didnt work @sage tendon
await ctx.send(message, discord.AllowedMentions.none())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Messageable.send() takes from 1 to 2 positional arguments but 3 were given
np
Can I set an embed footer to be a Discord timestamp?
The footer is made up of text, icon and a timestamp.
embed.timestamp to set the timestamp but this only accepts datetime so you cannot do relative timestamps
https://docs.pycord.dev/en/stable/api/data_classes.html#discord.Embed.set_footer can be used to set the text and icon
Thanks.
Does it does!bot.check_once apply for slash commands too?
Okay
how do i take eh choices from slash cmd and use it in the func parm
like i want to take the choice and use it as tag
Add it to the tag?
yes yes
like when i use slash commands it msut show the items in options
and when user selects one it must be used in tag
if not tag then i want to use it in the function
@commands.slash_command(
name="waifu",
description="Get A Random Waifu Image",
choices=["waifu", "maid", "oppai", "uniform", "selfies"],
)
async def waifu(self, ctx, tag = "waifu" ):
await ctx.defer()
try:
image_url = await swaifu(tag)
if image_url:
embed = discord.Embed(
title="OniChan Here I Am <3",
color=discord.Color.blurple(),
)
embed.set_image(url=image_url)
await ctx.respond(embed=embed)
else:
await ctx.respond("No Waifu Image Found For This Tag")
except Exception as e:
await ctx.respond(f"An Error Occurred : {e}")
here is the usage of tag
Here's the slash options example.
thanks
choices are part of an option, not of the command itself
ye i got it
and it's working thanks
np
a bot can change his pfp in a single server?
like using ctx.guild.owner returns the username only when i am the owner of the server
rest of the cases it says none
any idea why or how to fix
?
example 💀
uhhh 1s I did that somewhere
owner = await discord.utils.get_or_fetch(guild, 'member', guild.owner_id)
guild being ctx.guild
ahh thanks again sir
idk why its like that
it's just the guild owners member object so you can use it like one
ohh okkay
it shows like this using directly xd
yea that happens when you print a member object
Because that's what __str__ returns
ok i get ti
Why sometime loot task dupe?
Like if they have to send a msg or smt
They do two times
Is there a correct way to end a task to avoid that or something?
dupe ?
you mean it only work one time ?
No
Yeah, they duplicate
They work more than one time
For example a task to send a image at 3 in the morning for example
Something the task will work two times
And send two images
do you use shard ?
Idk what that is
can you check if you dont start the loop twice ?
and if you are stoping in when cog unload
No, just one .start at on_ready
(if you reload the cog maybe it does it 2 times
on_ready can be trigger more than one time
you can do something like that in your cog :
class Loop(commands.Cog):
def __init__(self, bot):
self.bot: commands.Bot = bot
self.loop.start()
def cog_unload(self):
self.loop.cancel()
@tasks.loop(seconds=30)
(that's what im doing)
seeing classes inside a bot hurts me
you are not using cog ?
yeah, default tasks loop
im almost sure you cant add the start outstide of the on_ready
directly on the code
nope
I add it bc when i search for tasks that was in the tutorial long time ago
alr, thx
with pleasure
Too fast
Does the timestamp show different value for different user ?
Like I’m in France it will differ than something in us ?
(In the same embed)
yes, timestamps are localised
Hi guys, i have a strange error: im using async def ban(ctx: discord.ApplicationContext, member: discord.Option(discord.Member, description='Choose a member', required=True), but when im trying to ban, i get error ('User' object has no attribute 'ban')
But im using discord.Member class, not discord.User
are you sure you selected a member that is in the server?
also just fyi, required=True is the default, you don't explicitly need it

oh
The method name is quite literally explicit
Message.publish?
I think that if you select a user outside a guild it convert it into an user. I’m not sure I will check that in a minute
i already asked a question that will answer that
that will not really answer my question
im more asking if a discord.Member in a slash command also convert into user
whatever i cant find anything on the github about that so if someone know that pls ping me
It's possible to make slash command hiden only for specific users?
users no, permissions yes (by default, without using server settings in discord)
It's possible to make command visible for administration users?
I mean whos have administration in server
Or role
yes
How
@discord.default_permissions(administrator=True) below the slash command decorator
Okeyy thank you
i have mor as one button in my slash command
how to add to view?
await ctx.respond(embed=embed, view=[view_invite, view_sup])```
this is not right
Learn all about implementing buttons in your Discord Bot using Pycord.
i have not a class for the button
i have thin in the slash command
i found this not
?
In one class add different button( example below is the wrong one)
Here's the tic tac toe example.
i already sent them the guide
Since he doesn’t use a class I’m trying to find the thing he wants
What they need is the correct way to make a view, which is described very clearly in the guide
there is not only one way to make view
are you talking about something like that ?
view = discord.ui.View()
button1 = discord.ui.Button()
button2 = discord.ui.Button()
view.add_item(button1)
view.add_item(button2)
await ctx.respond(view=view)
sigh
thanks
thats a terrible way to make a view
depends
if for example you use disabled button or link button its easier
than creating a class
not reusable, no easy way to add callbacks from what I can see, every guide about views in pycord does it the definition way, by using a class
but i guess just copying any code in chat works better for them than reading a guide so what gives
view = discord.ui.View() here its a class
No, that's just an object instantiation of the default view class, not defining a custom class to handle things better
as i said it depends on the utilisation, there is no better way, it depends only about what you need
i can also make a string by making a list of chars
or i could just make a string
@commands.command(brief=chef_showdown.short_doc)
@is_owner_or_has_perm()
async def chef_showdown(self, ctx: commands.Context, channel: discord.VoiceChannel = None):
channel = channel or ctx.author.voice.channel
invite = await channel.create_activity_invite(
activity=1037680572660727838,
reason="Launch activity",
max_age=0,
max_uses=0,
)
embed = discord.Embed(title=chef_showdown.embed.title, description=chef_showdown.embed.description.format(channel=channel))
embed.add_field(name="Channel vocal", value=channel.mention, inline=False)
embed.set_image(url="https://cdn.discordapp.com/app-assets/1037680572660727838/1107690679750115338.png?size=300")
button = discord.ui.Button(style=discord.ButtonStyle.link, label=chef_showdown.button.label, url=invite.url)
view = discord.ui.View()
view.add_item(button)
await ctx.reply(embed=embed, view=view)
Why do you think every pycord guide handles views by making a subclass of the view class?
here for example, i find it easier to just use the discord.ui.View than creating another class
they also use view = discord.ui.View() sometime
for example when the button does nothing, like button link
that is a very specific example
and if they just read the guide, they'd know how to properly do guides
this way, they probably just copy pasted your code and will be back here sooner or later because of its shortcomings
im not saying class are not better in general
i agree that class are better for a lot of reason, callback etc etc
but there is some case where it can be useful to also do view = discord.ui.View(), even with a class in addition
it does
when you set discord.Member as an option, a slash-command-user types a member, e.g.
@fresh sierra
then You leave the server and finally after you left the command user hits enter
you will receive discord.User instead of discord.Member
does anyone have a open source working pycord bot
This page showcases the amazing things created by the Pycord community, including bots, Plugins, and more.
how do i create like a task that runs infintely? i just need it to make a check every minute but im not sure how id create a task with pycord
Concept
@tasks.loop(seconds=5.0)
async def check_slot(self):
print("Running task!")```
I have this in a cog which also contains a command, not sure if thats important, but i dont think the task is running as that never gets printed
Did you start the task?...
i didnt see how to in the docs unless i completely missed it
oh i did miss it
ðŸ˜
def __init__(self, bot):
self.bot = bot
self.check_slot.start()
def cog_unload(self):
self.check_slot.cancel()
@tasks.loop(seconds=5.0)
async def check_slot(self):
print("Running task!")```
still nothin
Is the decorator correctly indented?
Mind showing a screenshot of your code instead?
Is the cog getting loaded?
yep
well thats not ideal lmao
Thanks u man
Can you show us the whole cog ?
Can you show how you load the cog?
how to create command group in cogs? there is no guide about it in docs
use discord.SlashCommandGroup(...)
I'm p sure there is a guide about that though
and then you use
@groupname.command() instead of the normal slash command decorator
so
testgroup = discord.SlashCommandGroup(args)
@testgroup.command()
async def commandname():
...
discord.SlashCommandGroup
discord.SlashCommandGroup.checks
discord.SlashCommandGroup.copy
discord.SlashCommandGroup.create_subgroup
discord.SlashCommandGroup.default_member_permissions
discord.SlashCommandGroup.description
discord.SlashCommandGroup.description_localizations
discord.SlashCommandGroup.guild_ids
discord.SlashCommandGroup.guild_only
discord.SlashCommandGroup.name
discord.SlashCommandGroup.name_localizations
discord.SlashCommandGroup.nsfw
discord.SlashCommandGroup.parent
discord.SlashCommandGroup.subgroup
discord.SlashCommandGroup.walk_commands
Here's the slash cog groups example.
the docs are different now
yea it wasn't a guide but an example, linked above, mb
tysm
what is the name of this status? it is not offline because i see it on the online members
is there even a status ?
how do you see the • admin .
hehehehe...
Yea, if you use unofficial client mods, expect them to mod your client
in what way do you need to read messages @dawn vault
for commands that aren't slash commands
ah, well then you do
intents = discord.Intents.default()
intents.message_content = True
bot = discord.Bot(intents=intents)
how do I add embeds too?
now I get this error:
bot.run(token)
File "D:\Python\Lib\site-packages\discord\client.py", line 716, in run
return future.result()
^^^^^^^^^^^^^^^
File "D:\Python\Lib\site-packages\discord\client.py", line 695, in runner
await self.start(*args, **kwargs)
File "D:\Python\Lib\site-packages\discord\client.py", line 659, in start
await self.connect(reconnect=reconnect)
File "D:\Python\Lib\site-packages\discord\client.py", line 598, in connect
raise PrivilegedIntentsRequired(exc.shard_id) from None
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.```
read it
But I enabled it
read the error :)
you enabled it in your code
but thats 1 of 2 places you need to enable it
?
just doing it in your code isn't enough
please read the error and do what it says
huh?
what is unclear
why I am getting the error
because you didn't do what it asks of you
?
The last 3 lines of the error. Read them, and do exactly what it says.
But I have it enabled
Again, just doing it in your code isn't enough

