#Basic Pycord Help
1 messages · Page 42 of 1
thing is thats true tbh
i'll prob end up removing that
i used to make it send something every couple mins now its hours
so i might jus change it tbh
you can just do that with a task
quick q you see how im switching to slash cmds how will i use https://github.com/Gorialis/jishaku
no idea what that is
lol nws
i think it was you that told me bout this
do i just simply do await interaction.defer() in order to not get the application failed to respond error?
in a command, its ctx.defer()
nah for buttons
it aint working tho
You cant. There might be a project out their but I have not seen any fully working slash versions. Also make sure that it does not install discord.py as a dependency. Also you should not need discord_webhooks as pycord should be able to do that. But I dont think it will cause to many problems if you keep it that way.
show your button code
ive removed the webhook thingy tbh dont need it anymore
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
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 ...
its interaction.response.defer
ohh appreciate it
Package Version
py-cord 2.5.0
pymongo 4.7.3
pip list ^
for the Option type, how can i make the autocomplete grab all the roles in a discord server? like Option(discord.Guild.roles) or something like that
Why use autocomplete in this case ?
Use only
input_type = discord.Role
You're using replit.
Import discord after the os.system
Also interaction.defer() should be at the beginning of the function not at the ened
Reinstall Pycord. Also is there a reason you have the os.system line?
because it’s replit
can you use an emoji as a thumbnail in an embed or nah?
if you have an image of it :)
thanks this helped!
with pleasure
Any way to make select menus remember selection after editing message?
just by not removing the view
it reverts to placeholder but i would like it to retain what the user selected
ooo
so no its not possible if you edit the view / response to the interaction
but why do you want to do that
there is maybe another solution
i know i can do it by selecting a default value when making a new select menu
but i wanted a simpler way lol
anyways thanks 👍
I may have run into a strange problem... i'm trying to get the bot to connect to the same vc i'm in, but it doesn't and also there's no error in console?
voice = ctx.author.voice
vc = await voice.channel.connect()
it get's the voice object as i can print it and see the channel i'm in, but it just doesn't connect! I have all intents turned on, it has the permissions to join, but nothing happens... Can someone give me a fresh perspective on this?
what pycord version
2.5.0
do you have pycnl
Oh crap i think i know the problem now xD If i recall correctly you used to have to download additional voice package? I haven't coded for some time and also had a fresh reinstall. Is it still the case?
try after installing that
PyNaCl
Yep it works now! Thanks Luma!
with pleasure
Now to just get it to play mp3 files xD fun
can someone help me please - i can't get my head around on how to do this:
category = discord.utils.get(interaction.guild.categories, id=1249341737973846036)
cito = discord.utils.get(category.text_channels, name=f"application-{interaction.user.name}")
if cito != None:
return await interaction.response.send_message("You already have a **Staff Application** ticket open!", ephemeral=True)
it doesn't work - no erros
What shows when you print category and cito
Staff Applications
None
wrong thing
one sec
there
If it’s None then it’s normal
but thing is there is a channel
Why don't you just use find on guild.text_channels
Or do you have to limit category
(Also this would break immediately if a user changes their name)
tbh i dont have to limit
yeah i realised that
but for some reason it didn't want to work when i used a db for it
example:
db1.find_one({"guild_id": interaction.guild.id})['user_id']
Idk but in the long run you basically need a db for ticket systems
yeah i do
cito = db.find_one({ "guild_id": interaction.guild.id })['user_id']
if interaction.user.id == cito:
return await interaction.response.send_message("You already have a **ModMail** ticket open!", ephemeral=True)
TypeError: argument of type 'int' is not iterable
i do understand the error but i can't figure out a way to check if ther user is in the db
db.find_one is returning an int
so just print the result and figure out what to do instead
yeahh i did it works now
nice
Hi, can someone help me out with the error: py 404 - Unknown Interaction
i know its caused by my bot taking too long to respond
so I tried out some code to immediately reply with a temporary message, then edit that response later, though the later edit is not working, it appears
Here's the relevant code:```py
Respond with a temporary message to keep the interaction valid
response = await ctx.respond("Working on it!", ephemeral=True)
...Do stuff that takes a while...
embed = discord.Embed(
color=discord.Color.from_rgb(75, 255, 75),
title="Success",
description=f"You have successfully granted {user.name} the {rank} tier in {kit}.",
)
await ctx.respond("", embed=embed, ephemeral=True)```
thats not how it works
use await ctx.defer() to tell discord to wait longer
that must be ephemeral if your response is, too
so at the top, I write await ctx.defer(ephemeral=True)?
yes
yes, and remove the temp response
Ok, I'll try that out now and update on whether it works, thanks
also just remove the "" in the respond, its not needed
will do!
Thanks a lot, it's working a charm
can someone help me fix my say cmd? it doesn't let me create a new line
show ur code
and describe what you actually mean
say i want to send a text:
Hey
How are you
not possible with options
with prefix it work idk for the other
maybe you can add a logic
like if the use put \n it goes into the line
also you forgot to actually send the message to the selected channel
and you can just pass the message variable directly, no need to make it an f String with nothing else in it
and you don't need the * argument for slash commands
and you don't need to pass the name= kwarg, it automatically takes the function name as command name
you dont need the * at the slash commad
too slow smh
I have a question. We can download pycord either by typing pip install py-cord or pip install py-cord[speed]. Latter variant claims to install some additional speed up packages. What are they? How exactly do they speed up bot?
I don't think it makes a noticeable difference unless your bot is huge
I think it just installs some more packages that you can use to do stuff faster, p sure it doesn't use them itself
I see, ok. Then it's probably useless for me
Thought this will speed up pycord w/o me needing to do anything to the bot itself
Meh tbh the biggest thing affecting most bots is latency, and db or api shit
and you can't really make that faster except by using async
True
do the buttons always stop working if bot goes offline then come back on?
unless you use persistent views, yes
What is the async timeout limit for pycord? Some of my responses that take 9-10 minutes are not returned
i send http post requests, the responses take 9-10 minutes
Used aiohttp for sending requests
to what?
I've my API endpoint
It's slow takes time to give a response
The bot forgets to fetch and give a response if it takes too long
your own API?
Yep
then.. make it respond faster?
The endpoint works I've tested it
Why does your api takes 10 minutes to respond?...
It's an llm I can't make it go faster
Gpu poor
Lmao
Can pycord increase the wait time? Is that possible?
I do not own the full stack I'm asking
I take your opinion and understand it
ctx.defer() extends it to 15m i think
but your solution is just... kinda bad, just use the API, you get a responds within 2-3 seconds at most every time
I understand your opinion, but some things have certain constraints.
I do not think groq endpoint is free
This is a small project
Yeah I'll check
i mean you absolutely can get away with 10 minutes on a request
kinda silly, better to improve the time, but nothing really stopping you
I just want to clarify. You can 100% put a string in an option. You just cannot do newlines natively. You might want to look at modals. This allows for more text manipulation.
is it not just putting timeout to none? if so ive done that
yeah i just decided to switch it to a prefixed cmd
there is a bit more to it.
Here's the persistent example.
You have to tell the bot what custom_id the component is so it can listen for interactions from discord matching that ID
oof.. worst way imo lol
would this have to be in the cog where my buttons are?
class PersistentViewBot(commands.Bot):
def __init__(self):
intents = discord.Intents.default()
intents.message_content = True
super().__init__(command_prefix=commands.when_mentioned_or(","), intents=intents)
self.persistent_views_added = False
async def on_ready(self):
if not self.persistent_views_added:
self.add_view(PersistentView())
self.persistent_views_added = True
print(f"Logged in as {self.user} (ID: {self.user.id})")
bot = PersistentViewBot()
But no, you can do this wherever
I do this in my main bot file
alright i'll test it out
for example I just have a views folder where I define all my views
with an init file so I can do from views import xview
ModuleNotFoundError: No module named 'discord'
i'm using a venv and i reinstalled py-cord
its not working for me in main file so i think i might need to do ur way
does anyone know if its possible to have a response send silent messages?
so basically have a slash command respond with a silent message
What do you mean by silent message ?
If you mean that does not ping anything yes you can
Or invisible u can to
yes to where it @s them without pinging them
i cant figure out how to do it with the ApplicationContext class though
if you do ctx.respond you are not pinging someone
You can use discord.AllowedMention
.rtfm allowedmention
that's completely unrelated lol
is it possible to defer prefix commands? My bot replies whenever it gets a ping.
I see that you require context to use defer, since I used an event on_message, I did not get a context.
What are you trying to achieve?
The only thing defer does is it gives you more time to respond to an interaction before it errors out.
hmm my bot takes some time, so I'd like it to defer it before it times out.
can we pass message as context?
Are you using bridge commands?
no im not
I checked the docs, I did not find a way to make the bot reply whenever it gets a ping (although I think it's possible?)
on_message doesnt need to be deferred
I think thats possible with bridge commands (both slash and prefix)
no i meant using this bot = commands.Bot(command_prefix="!", intents=intents)
I was able to get the bot to respond to pings in on_message() by just checking for bot.user.mentioned_in(message)
referred this btw: https://guide.pycord.dev/extensions/commands/prefixed-commands
Ah
you are looking for this then:
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...
Why defer a prefix command V
You don’t have a time thing using prefix
mhm i just want the bot to reply when i ping it. The API call is slow so I thought I'll defer it.
Defer is only for interaction so Dw about that
This might be the thing u want
(No that’s for prefix definition only
hmm I think defer is primarily for slash commands
for interactions
you have to respond in 3 seconds at interactions or you gonna get an error and with defer you can increase that time to 15 minutes
that does not exist at prefix commands
read the channel name
who can i share with him my code, i got error and i can't solve it
You post the error and relevant code here.
slash, prefix or bridge command?
slash
let's say i have this
settings = SlashCommandGroup("settings", "Settings Commands")
and the comamnd is
@settings.command(name="set_meme_channel", description="Set channel for memes")
async def set_meme_channel(
self,
ctx: discord.ApplicationContext,
channel: discord.TextChannel,
frequency: int,
):
meme_config[str(ctx.guild.id)] = {
"channel_id": channel.id,
"frequency": frequency,
}
save_json("MEME.json", meme_config)
embed = discord.Embed(
title="Meme Channel Set",
description=f"MEME Channel : {channel.mention} \nFrequency : {frequency} Minutes",
color=0x00FF00,
)
await ctx.respond(embed=embed)
how can i mention set_mem_channel command ?
you can get access to the command with the name of it
well
{self.bot.get_application_command('info').mention}
i used to mention the names like this
ohh i get it
so it will be like
{self.bot.get_application_command('set_mem_channel.name').mention}
oh ic thanks sir
I wonder what you gonna get from it xd
wwll what's wrong in trying xd
and learning
@harsh bloom just use the groq API dude
no one wants to wait 10m for a single command
you're making the experience worse for everyone involved for no reason
I solve it thank you
Whats groq api
lol you didn't leave that? yeah I've included that API
a free API for a servcie that runs LLMs extremely fast
but if you use it, why do you need this robin
can't I know how to get output from a slow api
i mean, groq never takes more than 3 seconds max
so you have another slow api?
let me rephrase
- "can't I know how to get output from a slow api using pycord"
Is there a way to get the count on connected members in a voice channel
i really dont get what you want to say
the solution to having a slow api is
- change the api if you can
- use aiohttp, never use requests
ideally, both
hi
U have a idea 👀
oh its you again, the guy allergic to the docs
I never touched voice in my life, and i was able to find it within 5 seconds TOTAL in the docs
Please, use the docs
I found the user limit
Found
That will not give u the number of member connected in a vocal
.rtfm voice.channel.members
Okay another question
Target not found, try again and make sure to check your spelling.
Got it already
try:
await ctx.author.voice.channel.connect()
except:```
Except will not be triggered
they literally said they found it already
and dont spoonfeed them, its proven not to help
them in particular
Install pynacl
yes
In what case this is trolling ?
Have u already install pynacl
@frail ocean did the install of pynacl solve ur case ?
And the Connect doesn’t work ?
Hi, can somebody please explain the difference between display_name and name? I don't quite get it
Is it that the name is just your username while display_name will be your nick, if you have one, but if you don't, your username?
name is their unique username
i see, thank you.
.tag pomelo
Before Pomelo- Versions 2.4.1 and before
member.name -> username
member.nick -> guild nick name
member.display_name -> member.nick OR member.name
After Pomelo- Versions py-cord-dev 2.5.0 and up
member.name -> username
member.global_name -> global display name (global nick name)
member.nick -> guild nick name
member.display_name -> member.nick OR member.global_name OR member.name
for more info ^
I see, but I'm getting another error with this:```py
await ctx.respond(embed=embed)
I get the error:```py
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: HTTPException: 400 Bad Request (error code: 40060): Interaction has already been acknowledged.```
Now, this doesn't cause the message to not be sent, but I would appreciate why it occurs, in case it causes some issues in the future
show more of your code
are polls supported in pycord?
Via the pending PR
thanks 👍
Why bot sometime raise this error?
Application Command raised an exception: AttributeError: 'MessageInteraction' object has no attribute 'locale'
i mean, the error is quite clear
read?
you are trying to access .locale of a messageinteraction object
that doesnt exist
what are you trying to do
can i build out a music bot which is compactable with pycord ? if so which module to use any references or so
like i am never successful with python to build a music bot
got a question, if I have a bot that is making views within threads, will the view overwrite itself on each new thread view that is created?
example: I have a yes button and no button inside a discord thread. I make a second thread with the same buttons and push the same view name to that new thread, will it kill the old buttons/overwrite them?
Each view is independent to its own message component
.tag wavelink
class YouTubeTrack_fix(wavelink.YouTubeTrack):
@classmethod
async def convert(cls, _, ctx: discord.ApplicationContext, argument:str):
return await super().convert(ctx, argument)
@slash_command()
async def play(self, ctx: discord.ApplicationContext, search: YouTubeTrack_fix):
if not ctx.voice_client:
vc: wavelink.Player = await ctx.author.voice.channel.connect(
cls=wavelink.Player
)
else:
vc: wavelink.Player = ctx.voice_client
await vc.play(search)
await ctx.respond(f'{search.title}')
FIXED
TypeError: SearchableTrack.convert() takes 3 positional arguments but 4 were given
thanks sir
Can you create a cog and have it and its commands fall under a slash command group?
You mean a group of slash commands? Or what do you mean?
I'd like the cog itself to be a subcommand of a parent SlashCommandGroup
Essentially, I'd like all my commands to adhere to the following structure heirachy:
/{basegroup} {cogname} {commands-inside-cog}
The basegroup would be universal, so ideally I'd define that in my main python file and then pass the context into the cog - having some issues passing the context in and accessing the value inside the cog class
you need to use py-cord multicog
This looks promising - does the parent group have to be defined inside a cog, or could you define it elsewhere?
you can defnied it where you want and then just do
@subcommand("name_of_group")
async def command()
Perfect, thats exactly the functionality I was hoping for originally - much easier to write a string than pass the context through classes
Hello, looking at the doc, i saw
Context = Union[BridgeExtContext, BridgeApplicationContext]
to get the union of both, since im using a custom context, i decide to do the same :
However when using it as typehint i got that error :
2024-06-11 06:30:28 [WARNING] : Failed to load extension Slashs.Anime.smile: Extension 'Slashs.Anime.smile' raised an error: TypeError: Invalid usage of typing.Union
@subcommand(f"bot")
@bridge.bridge_command()
async def exec(self, ctx: LumabotContext, code: str):
class Lumabot_App_Context(bridge.BridgeApplicationContext):
...
class Lumabot_Prefix_Context(bridge.BridgeExtContext):
...
LumabotContext = typing.Union[Lumabot_App_Context, Lumabot_Prefix_Context]
and im also getting the good context
async def get_context(self, message: discord.Message, cls=Lumabot_Prefix_Context):
return await super().get_context(message, cls=cls)
async def get_application_context(self, interaction: discord.Interaction, cls=Lumabot_App_Context):
return await super().get_application_context(interaction, cls=cls)
Was wondering, is it possible to get title and description of link embeds and whether a link was embedded directly from discord or do I need to check manually with something the open graph meta tags
embed.url ?
Yeah but I mean with embeds that come from links - not embeds crafted by the bot. Do they work the same?
an embed is an embed
so if you have a link of a message
just access to the embed of the message
👍 thanks
I'm trying to get user language. I checked command with my or my friends accounts and it works fine, but sometimes it raises that error for random people.
what's your code for it
It’s ctx.locale
What about ctx.interaction.locale?
Now I understand...
no.... ctx.locale is ctx.interaction.locale
oooooo its a shortcut ?
mb then
basically everything on ctx is a shortcut
thanks for that
then for prefix command
how can you get the local since there is no interaction ?
i have my reponse, you dont
you don't
locale is exclusive to interactions
Yep, when bridge will be supported I will have to do some workaround
is there a way to start the new shard when a bot is joining much servers without having to restart the full bot ?
Not possible I think because share are start when the bot begin to run
locale = ctx.guild.preferred_locale if not ctx.is_app else ctx.locale or ctx.guild_locale
okay but if there is an event listener for shard ready, there is no way to tell the bot to start the new shard provided by discord ?
like on all on_guild_join events, a verification of the shard number is sent to discord, and if the number is different from the actual one, just start the new shard
same for on_guild_remove
i think there is not methode to actually start a shard
or maybe autoshardedbot handle that itself but i dont think
no it does not, that's why I am asking for this
there is a method shard connect
maybe if you edit the bot.shard_count while running to a bigger value
and then do for shard_id in shard_count get_shard then shard.connect
(need to be test but i dont see why it will not work)
Yeah I will see, thanks
too short to thanks me, first look if it works ;)
Can I tag an entire cog to fall under a group? In my main bot.py I am defining my base command group (/command), defining a couple of basic commands under it, then loading cogs afterwards. As mentioned above, I'd like for my command structures to be /command cog cog_subcommand - any suggestions as to how to implement that with this package?
I think the easiest way I do to add the decorator@subcommand before each @command
There is other way to do that with some file / folder but it’s way harder and I never did that
So would it be like below?
@subcommand("command")
@subcommand("cog")
@command.command(name="XX")
async def blah(self, ctx):
await ctx.respond("Hi")
This is within my cog's class
Nah j understand know what you mean
First you create ur group
group = discord.SlashCommandGroup(name="group")
subgroup = group.create_subgroup(name="sub")
And then you do
@subcommand("group sub")
Im on phone so its normal for the missing codeblock +other thing
Ok ok, I get it. Let me try that out
import discord
from discord.commands import SlashCommandGroup
from discord.ext import commands
from pycord.multicog import Bot
owner_id = 0000000000000
intents = discord.Intents.default()
bot = Bot(auto_sync_commands=True, intents=intents, owner_id=owner_id)
cmds = SlashCommandGroup("basegroup")
@cmds.command(name="ping", description="Pong!")
async def ping(ctx):
await ctx.respond("Pong! 🏓")
# Load default cogs
modules.cog.setup(bot)
# Start the bot
bot.run(token="XXX")
import discord
from discord.commands import SlashCommandGroup
from discord.ext import commands
from pycord.multicog import Bot
from pycord.multicog import subcommand
class Cog(commands.Cog):
def __init__(self, bot_: Bot):
self.bot = bot_
subcommand_group = SlashCommandGroup(name="cog")
@subcommand("basegroup cog")
@commands.slash_command(name="XX")
async def blah(self, ctx: discord.ApplicationContext):
await ctx.respond("Hi")
def setup(bot: discord.Bot):
bot.add_cog(Cogs(bot))
Getting the following error message when running
I'd wager its probably the way I'm defining the subgroup in the bottom code block, however, I get a similar issue when creating the subgroup off the cmds object context
If I drop the subcommand_group = SlashCommandGroup(name="cog") in modules.cog.py and add cmds.create_subgroup("cog") below cmds = SlashCommandGroup("basegroup") in bot.py I get the same thing
And to do that it should be on the same file for the creation of group and subgroup
Can you show me the updated cog ?
And the decorator should be just upper the @commands
Not with a different identetion
import discord
from discord.commands import SlashCommandGroup
from discord.ext import commands
from pycord.multicog import Bot
owner_id = 0000000000000
intents = discord.Intents.default()
bot = Bot(auto_sync_commands=True, intents=intents, owner_id=owner_id)
cmds = SlashCommandGroup("basegroup")
cmds.create_subgroup("cog")
@cmds.command(name="ping", description="Pong!")
async def ping(ctx):
await ctx.respond("Pong! 🏓")
# Load default cogs
modules.cog.setup(bot)
# Start the bot
bot.run(token="XXX")
import discord
from discord.commands import SlashCommandGroup
from discord.ext import commands
from pycord.multicog import Bot
from pycord.multicog import subcommand
class Cog(commands.Cog):
def __init__(self, bot_: Bot):
self.bot = bot_
@subcommand("basegroup cog")
@commands.slash_command(name="XX")
async def blah(self, ctx: discord.ApplicationContext):
await ctx.respond("Hi")
def setup(bot: discord.Bot):
bot.add_cog(Cogs(bot))
Also you should not change the type hint to Bot, continue to use the commands.Bot
Here the @decoezror is not well place
Im on phone so maybe
But it doesn’t appear
Can you do a screenshot ?
The ping command isn't what I'm concerned about - I haven't used @subcommand with that
Im talking for the XX commands
It looks good, when you run that specific code what does it return ?
This is when ur run the code ?
Can you show me how u load the cog ?
In bot.py I call modules.cogs.setup(bot) which runs the setup function at the bottom of the modules.cog.py screenshot
Prior to trying to implement all this subcommand stuff, this all worked fine and it would launch
Did you read the error
Yeah but the error should not occur since both group has been vreated
?tag paste
Please copy and paste your code here. This makes it easier for everyone helping you.
Can you put all ur file there
Yes, however, I don't think I would want it to be independent (if I'm properly understanding what independent actually means)
I go at my house and then check from my Mac
Indépendant mean not in a group
you should use the bot.load_extention("modules.cog")
try and see if it fix it
ok, lets give that a go - for my own understanding, what's the difference?
load_extension is how you run cog
basically
Was I meant to replace the code in bot.py or modules.cog.py sorry?
just the one in bot.py
by removing the modes.cog.setup(bot)
and also, remove the import modules
because to do modules.cog.py , you need to import it, and import it will run the cog before running the creation of group
and because of that u have this error
Ok, I've made those changes but I'm still getting the same error
my folder structure is like this:
| src
| - bot.py
| - modules/
| - cog.py
I'm referencing it correctly here yeah?
but this thing is strange the red thing
is that an extension ?
let me try ur code
let me try
can you do a pip freeze
and give it me what it return ?
aiohttp==3.9.5
aiosignal==1.3.1
attrs==23.2.0
frozenlist==1.4.1
idna==3.7
multidict==6.0.5
py-cord==2.5.0
pycord-multicog==2.1.1
python-dotenv==1.0.1
yarl==1.9.4
here how you can do
you apprenlty cant define group in main
so by putting the init you can put everything
ok, so basically what we're seeing is it loads cogs to the command list before the commands we define loosely in non-cog classes, and as a result we aren't actually initialising our command groups before the cog gets loaded
Everything is now working as intended, thanks for your help @fresh sierra
the init is load first so yes
with pleasure ;)
Hello, I am encountering a strange issue with my bot. Though it appears online, and the console shows no sign of it going offline, after using one slash command, the bot's slash commands cannot be found again? I do not know why this could be happening
Uhh, make sure you're not running multiple instances.
Do you use cogs?
strange there is someone else with that issue
maybe he did find a solution since
Nope
I don't think i am
That isn't the issue I'm encountering, like the slash command just disappears from the menu. It works once after the bot has been started
I have the source code of the bot on my github: https://github.com/SDSCodes22/PvP-Practice-Bot
have you considered using cogs
why would I need them? I don't know what they are - I thought they were for grouping commands
Yea, have you looked at your bot file? its huge
well okay 300 lines isnt huge but in the scope of a discord bot (main.py), it is
Yeah, is there a way to like separate each command into its own file? That would be helpful tbh
no, thats just unnecessary
use cogs
one command per file is too much
cogs typically make you put several similar ones into one file, which is well enough
Cogs, often known as modules or extensions, are used to organize commands into groups. This is useful
thanks, I'll look into that, but my original issue of the slash commands seemingly stopping to exist continues to perplex me
and no clue, your code is kinda messy because its all in one file, but i cant see anything that would cuase that
just really make sure your bot isnt running twice, reset the token if you want to make double sure
You can using cog and making one command in each cog
alright
wat
show code
this is it
Yeah, it's in a cog
are you sure this code is causing that?
what did you last change since it worked
also, don't use has_permissions with slash commands
I added in logging when settings are changed
and what replacement should I use for has_permissions
the @analytics? well, then try to find what it touches and make it not break stuff
discord.default_permissions
That didn't break anything since the time it was added, it's been there for over 5 months in production and hasn't thrown a single error
so you changed nothing about the code of the command?
Nothing above the async def, only the contents of the function
and the traceback shows that command being the issue?
No, the screenshot I posted is the whole log, alongside a ready message
I have it set on debug mode
Can you try without some decorator to troubleshoot it ?
Ok I tried it again without changing a single thing in the code and now it works
interesting
How do I accept an emoji as an option of a command?
discord.Emoji in option type doesn't work properly
It only works with custom emojis, but I want the default ones too
Please reply ping to me, I'm going to go sleep now
is there anyway object for guilds like we have for members for easy choosing of members
like
user: Option(discord.Member, "Mention the user you want to send", required=True)
No
You'd have to create an autocomplete yourself
Can you show your command?
Currently not at the PC, so I can't, but there's one parameter emoji: discord.Emoji
This parameter causes the warning above, unless a custom emoji is supplied
That's just for discord emojis. If you want default emojis it is not necessary
I want both
I dont even really know if its possible to do the stuff with the emojis
Check partial emoji
Ok, once I get home
discord.Emoji is a valid command option??
Well
I know I tried that at some point and it was not working
it would definitely be very new to me
According to ddev docs it is not
but how
If I do str(emoji) it does :heart: for ❤️ and  for
, right
i mean yea but im still flabbergasted about discord.Emoji as an option type
are you very sure it doesnt just fall back to str
it works with custom emojis
Im going to try PartialEmoji as it should work with unicode ones, there's is_unicode_emoji()
emoji is not a slashcommandoptiontype
yea, neither emoji nor partialemoji is
apparently it still works and is passed as a emoji, but thats undocumented then
i really doubt this is intended behaviour
i tested it
yea, i just tested it
its a complete mess, undocumented, probably unintended, and doesnt work properly
Ignoring exception in on_message
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/yon/.local/lib/python3.10/site-packages/discord/client.py", line 378, in _run_event
await coro(*args, **kwargs)
File "/home/yon/test/point/cogs/Points.py", line 242, in on_message
await message.add_reaction("✅ ")
File "/home/yon/.local/lib/python3.10/site-packages/discord/http.py", line 283, in request
async with self.__session.request(
File "/home/yon/.local/lib/python3.10/site-packages/aiohttp/client.py", line 1167, in __aenter__
self._resp = await self._coro
File "/home/yon/.local/lib/python3.10/site-packages/aiohttp/client.py", line 562, in _request
conn = await self._connector.connect(
File "/home/yon/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 540, in connect
proto = await self._create_connection(req, traces, timeout)
File "/home/yon/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 901, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
File "/home/yon/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 1169, in _create_direct_connection
raise ClientConnectorError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host discord.com:443 ssl:default [Temporary failur
e in name resolution]
what cause this error? other bot in my vps doesn't have this issue, it's always happen when using Message.add_reaction()
and happened everyday
and how i handle automatically?
Seems like an issue with ur host
Like an internet error
Maybe try to reinstall pycord bit I don’t rhino it will resolve it

I settled on using this as my code
how do i check if a button is clicked or not
?
view = discord.ui.View()
yes_button = discord.ui.Button(label='Yes', style=discord.ButtonStyle.green)
added this to my embed
Youre supposed to subclass the view class and add the buttons with their callbacks there.
https://guide.pycord.dev/interactions/ui-components/buttons
Learn all about implementing buttons in your Discord Bot using Pycord.
alright thanks
why ctx.response.send_message?
It was similar in discord.py
ctx.respond
Before I switched to this library
I haven't studied it too much but this seems to work so I used it, but now I'm going to replace all ctx.response.send_message() with ctx.respond() using a regex
woah there's a lot
also, you have the exact same line of code three times, that code doesnt adhere to DRY :3
It's a bit messy I know
it is intended because it's a Converter class
all Converters and their related classes are acceptable types, giving parity to prefix commands even when limited to string
it'd be nice, but unicode emojis are just considered strings; the Emoji class is targetted towards custom emojis
50% of the time when commands are run it gives 404 unknown interaction but then other times it doesnt?
Can you show the command?
Anyone know why my slash command with the @has_permissions(administrator=True) decorator triggers false negatives?
because you should not use that decorator with slash commands
wdym
it's an internal check, nothing wrong with it
you should always use default_permissions
not necessarily
I haven’t been able to replicate it, but I’ve had several users say they have admin but that error message gets triggered anyway. Then after they wait a while and run the command again with the same permissions, it works. They could be wrong but wanted to check here first just in case
in 95% of cases
are you sure it's not a different error and perhaps you're try-catching too broadly?
they're not equivalent, default_permissions is freely controllable by other members in the guild while has_permissions is not.
ultimately it depends on your goal.
i am well aware of that
This is how I’m handling it:
@toggle_integrated_ticketing.error
async def toggle_integrated_ticketing_error(self, ctx, error):
utilities = self.bot.get_cog("Utilities")
if isinstance(error, MissingPermissions):
await utilities.send_command_requires_admin_error_msg(ctx)
but default permissions hides the command which is what people generally try / want
right, but the point is if you don't want it useable at all then has_permissions is objectively safer.
either only default, or both.
could you perhaps log the author and permissions that were missing?
the error has a missing_permissions attribute which is a list of what failed
it would be easier if some pattern could be found, im guessing cache is weird about it but not sure
Definitely, I’d just rather not fill up a log file or display a messy error to the user. For the purpose of fixing this I could though
yeah just some quiet logging is fine
either way, consider switching to default_permissions unless you have reasons not to
because typically you also wanna hide admin commands from non admins
I’m fine with non admins seeing the commands. I only have the admin requirement set because the commands change the guild’s configuration for the bot. I’d rather have users see the error message and realize they need admin than not see the command entirely and come complaining in the support server
thats... a unique reason lol
how would they even know it exists when they never see it lolw
Tutorials and documentation. I see your point, that's just not the way I'd rather implement it
I've made a cog to implement CaptchaVerification into my bot. When running the bot, I get the following error:
discord.errors.ExtensionFailed: Extension 'cogs.CaptchaVerification' raised an error: AttributeError: 'AutoShardedBot' object has no attribute 'add_command'
I have looked into this with the docs, and my syntax is how the docs said it should be:
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
extName = filename[:-3]
bot.load_extension(f'cogs.{extName}')```
Anyone got any ideas on causes?
This is what is raising the exception btw: File "C:\Users\there\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\cog.py", line 562, in _inject
Can you show the pip list pls
You're about to get the text equivalent of a zip bomb.
okay nevermind its 1800 characters too long for me to send
Okay there we go ^
mhm
Does anyone know why I get this error while trying to install the turtle library?
it would need to be py except ValueError as ve: <code>
do you use any old system?
or any old windows versions?
I do
It's a very old copy of Win10, most likely a compatibility issue. What version of python is it?
3.8
@nova epoch at how many servers is your bot?
One at the moment. Hoping to scale it in the future though.
how did you define the bot?
intents = discord.Intents.default()
intents.members = True
intents.messages = True
intents.message_content = True
intents.guilds = True
intents.guild_messages = True
bot = discord.AutoShardedBot(intents=intents)```
if your bot is not at 2500+ server you dont need AutoShardedBot
You only need intents.message_content = True since u are using default
just use discord.Bot()
I think it’s better when it’s in more then 1000
(It will automatically pop a shard)
I did have discord.Bot, I only changed it to see if it would sort the error. It did not :(
I know, it's just clearer to me so I like to have it like this.
Okay
What ur issue I didn’t really understand
It's all here.
I look at that when im at house
guys I'm still learning so just wanna know how often do u use RegEx and do I have to know all the syntaxes?
I find regex to be quite useful, but it depends with what you're making.
No, you can use tools online to generate regex expressions without having to know the syntax. I would suggest learning some basic syntax for pattern recognition though.
ok, tnx
Rule #1, you dont learn regex
you use https://regex101.com or similar stuff
Rule #2, avoid regex if at all possible
what are you talking about, regex is a great tool
i know
discord.Bot doesn't support prefixed commands.
So add_command doesn't exist in discord.Bot
GMGM!
call = SlashCommandGroup("postcall", "Publish Post Commands", guild_ids=adminServer)
# DeFi Updatez
@call.command()
async def defi_update(self, ctx: discord.ApplicationContext):
await ctx.respond('<3')
rookie question, but where can I add the description* for the slash command defi_update?
description="" at the command
;3
that, or as a docstring using """ this syntax """ right under the function definition
Idk this will work for everything, ik for prefix it’s considered has short_doc or brief and not description (in my memory)
So description= should be better
man idk but thats not a bridge command to me
and it should work just fine on bridge too
Still a thing to consider because we never know
completely unnecessary
You should use description=
meh, doesnt matter
Is there a way to load cogs without it invoking a missing bot.add_command?
None of the cogs it is loading even have a text command, it's all interactions :/
bot.load_extension
That's what I'm using, but that invokes bot.add_command:
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
extName = filename[:-3]
bot.load_extension(f'cogs.{extName}')
print(f"Loaded cog: '{extName}'")```
it should tell u the issue if there is one
you can do
bot.load_extension("cogs", recursive = True)
and it should trigger the setup more at the end of ur cog
can you show me how does look ur cog ?
The setup is literally py def setup(bot): bot.add_cog(VerificationCog(bot))
The actual cog is way too long to put here
show your pip list, show your bot variable definition
Bot definition
Pip list
ah
ur not using prefix right ?
Nope
can you show me how does look one of ur command ?
well, i definitely saw that error before
just the command definition
The command itself is this
@commands.command(name="verify", description="Begin your verification attempt.")
async def verify(self, ctx):
verify_url = f"https://{api_url}/?discord_id={ctx.author.id}&site_key={self.turnstile_site_key}"
embed = discord.Embed(
title="Human Verification",
description=f"Please verify you are human by clicking the link below and completing the Turnstile challenge:\n[Verify Here]({verify_url})",
color=discord.Color.blue()
)
embed.add_field(name="Note", value="Powered by Cloudflare Turnstile Enterprise")
view = discord.ui.View()
view.add_item(VerifyButton(self, ctx.author.id))
await ctx.send(embed=embed, view=view, ephemeral=True)```
this is for prefix
@commands.command
that ur issue
you should use @discord.slash_command
no, in cogs it's @discord.slash_command
i thought they were aliases 😭
dw
also, why not make a proper view subclass with the button you want
like this button?
class VerifyButton(discord.ui.Button):
def __init__(self, cog, user_id):
super().__init__(label='Submit Verification Token', style=discord.ButtonStyle.primary)
self.cog = cog
self.user_id = user_id
async def callback(self, interaction: discord.Interaction):
await interaction.response.send_modal(VerificationModal(self.cog, self.user_id))```
well you can just do
instead of
view = discord.ui.View()
view.add_item(VerifyButton(self, ctx.author.id))
do
await ctx.send(embed=embed, view=VerifyButton(self, ctx.author.id), ephemeral=True)
im almost certain thats not how views work
the view works fine (to my knowledge)
i guess we';; see
IT HASNT ERRORED THIS TIME GUYS
1m ill test
yea ok i broke it gimme a min]
mb i didnt see it was a discord.ui.Button and not view
It worked for them after waiting for a while. I didn’t add the logging yet. I’m assuming this means it’s probably related to caching? This is similar to what other users experienced as well
hi, I made a silly webhook generator to imitate friends on our server like:
@bot.command(description="Imite un utilisateur")
async def imite(ctx, user: discord.User, *, message: str):
avatar = await user.avatar.read()
webhook = await ctx.channel.create_webhook(name=user.nick, avatar=avatar)
await webhook.send(content=message)
await webhook.delete()
how can I setup the color of the nickname, it would be better but i can't find anything on the doc or internet about it 😦
please telle me there's a way
Not possible for webhooks
Kinda a stretch, but could you see if has_guild_permissions is any more reliable?
I have a quick intent question:
I did this (and enabled the intents in the dev portal)
intents = discord.Intents.default()
intents.message_content = True
intents.members = True
But now, when I receive an on_message event, I don't get the Message.content. But when I fetch messages with e.g. Channel.history, I do get the content? Why is that? Did I set the intents right?
It's also weird, because a few days before it did already work using exactly this setup...
.tag intents
Pycord Docs - Intents
Discord API Docs - Gateway Intents
import discord
from discord.ext import commands
# Get specific intents for fine control
intents = discord.Intents()
intents.emojis = True
intents.guilds = True
intents.messages = True # Required for prefix commands!
...
# Get all non-priveliged intents; this excludes presences, members and message_content
intents = discord.Intents.default()
# Set priveliged intents: these must be enabled on dev portal
intents.members = True
intents.presences = True
intents.message_content = True # Required for prefix commands >= 2.0.0b5
# Get all intents; all intents must be enabled on dev portal.
intents = discord.Intents.all()
# Apply intents when creating your bot
bot = commands.Bot(prefix="?", intents=intents)
Strange because it should work, does ur bot have the correct permission ?
Don't you need .guilds and .messages ?
comes with default
ah
yeah, nothing changed afaik.
It's a bot I wrote for someone else, and they came to me because it didn't work anymore.
Can confirm that the code is correct
They asked here themselves already (and solved it by replacing the default with all) but I don't understand what the issue was...
https://discord.com/channels/881207955029110855/1251082779861454868
oh nvm
they actually still had an older version where there was only default() set.
im reloading my cog which adds my new print statement but doesn't remove my old print statement, i don't receive any errors what could the issue be?
Where's the print?
There is an issue here where when unloading a cog doesn’t remove old command so it might be ur issue
Is it possible to make my bot use all CPU threads instead of just one?
If your command is very CPU intensive you can you can use multi threading to use more cores
Or if your bot has a lot of guilds, you can shard the bot
why?
My bot uses the on_guild_available event on startup to do some checks.
go on
Im using AutoShardedBot.
?
why does this need multithreading
also, isn't that event meant for servers that basically go offline?
Because as soon as I have this event called 200 times (200 guilds), my load increases to 100% on 1 thread and 0% on the remaining 35 threads and it lasts almost a minute.
well, what are you checking with that event?
its really not something you need typically because guilds rarely ever go offline
your case seems more like you want to check all guilds once the bot starts
I have checks there such as adding guilds to the database if not exist, removing unnecessary temporary voice channels completing giveaways, etc. My bot should always check this on startup for each guild.
then just iterate through all guilds
you're kind of absuing that event lol
just use bot.guilds and iterate through it, with asyncio.sleep possibly so you can regulate the speed
Before that I did it via on_ready but it produced exactly the same load and the same execution time
async db calls?
Yea
can you show your code if it isnt too much?
because, for real, your CPU usage shouldn't go to absolutely 100% for a minute
I'm on phone
well then, do it when you can
Check for any recursive function about that
does pycord not have any way to manually shard to 36 threads?
but really, you should just iterate through bot.guilds
i dont think you understand how sharding works
Does it just use a separate websocket connection only?
almost certainly
In djs there was a hacky way to run a single bot on multiple servers iirc
Does pycord not have anything like that?
think someone said you can, but you have to manually specify shard ids per machine
Yeah you have to do the same in djs
Yes that possible with cluster
what is create_task?
Also I mean
You iterate through every guild, and potentially every of those guilds' members
That is... a lot
Is there anything against using fetch over gets methods. Wouldn’t be called in loops or anything. Just hate how discord client cache is crap and I can never see the mention names in my moderation embeds.
its asyncio.create_task
that has nothing to do with fetch or get
mentions in embeds don't resolve properly, thats just a discord bug
But generally, avoid fetch if you can
Roger
ping them in the content, thats how i do it
that way, if you leave the embed ping there, that'll also work if the normal ping resolves fine
Thats 14588 users.
How can I improve speed?
yea, well, why do you need to iterate through so much on every bot start
thats the first thing you could work on lol
and again, if time isnt critical, iterate through bot.guilds and use asyncio.sleep to regulate sleep
Why aren’t u using some loop ?
It will delay the process and not put everything in one time
(Task.loop)
So you can do 3 différents loops one for giveaway one for voice one for autorole
How
:> this still applies
.rtfm tasks
discord.ext.tasks.Loop
discord.ext.tasks.Loop.add_exception_type
discord.ext.tasks.Loop.after_loop
discord.ext.tasks.Loop.before_loop
discord.ext.tasks.Loop.cancel
discord.ext.tasks.Loop.change_interval
discord.ext.tasks.Loop.clear_exception_types
discord.ext.tasks.Loop.current_loop
discord.ext.tasks.Loop.error
discord.ext.tasks.Loop.failed
discord.ext.tasks.Loop.get_task
discord.ext.tasks.Loop.hours
discord.ext.tasks.Loop.is_being_cancelled
discord.ext.tasks.Loop.is_running
discord.ext.tasks.Loop.minutes
discord.ext.tasks.Loop.next_iteration
discord.ext.tasks.Loop.remove_exception_type
discord.ext.tasks.Loop.restart
discord.ext.tasks.Loop.seconds
discord.ext.tasks.Loop.start
How would i save attachments to a specific folder?
add the folder path?
async def download_attachments(channel):
for message in channel.history(limit=None):
for attachment in message.attachments:
save_path = os.path.join(parts_directory, attachment.filename)
await attachment.save(save_path)
I thought this would save the attachment to my parts_directory
lemme get the attachment stuff, 1 sec.
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 ...
Cheers
take a look at that
Do we have something like on_raw_reaction for Buttons such that the buttons responds even if the instance is re-run..
that is for emoji reactions
yes, can we make it work for buttons?
functionality of on_raw_reaction but for UI Buttons.
the event is called on_interaction
yes, but let's say I re run the bot - the same button no longer responds.
I want it to be able to 'revive' the button so it continues to respond - just like reaction emojis do in on_raw_reactions
you need persistent views for that
and you dont need to listen for any event for that
Does PyCord support user apps yet?
not on stable, no
I run off of master anyway
Well I pin to specific commits, I'm not a complete maniac
master should have it
there’s a pull request, just waiting for discord to finalize it ##2409
No GitHub issue or pull request mentions (ex. #123) found.
same
Thank you, exactly what I need.
Can I ratelimit button presses
yes
Ok thanks
Hi. I'm trying to create permission overwrite for specific roles when creating a category
Code:
moderatorsRole = await guild._fetch_role(ModeratorsID)
# 1v1 Cateogry
perm1v1Challenge = {
guild.default_role: discord.PermissionOverwrite(send_messages=False, view_channel=False),
judgeRole: discord.PermissionOverwrite(read_messages=True, send_messages=True, view_channel=True),
moderatorsRole: discord.PermissionOverwrite(read_messages=True, send_messages=True, view_channel=True),
guild.me: discord.PermissionOverwrite(read_messages=True, send_messages=True, view_channel=True)}
category1: discord.CategoryChannel = await guild.create_category(name="🟢┊Ongoing 1v1 Challenges", overwrites=perm1v1Challenge, position=0)```
**Error:**
``` category1: discord.CategoryChannel = await guild.create_category(name="🟢┊Ongoing 1v1 Challenges", overwrites=perm1v1Challenge, position=0)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
data = await self._create_channel(
^^^^^^^^^^^^^^^^^^^^^
"id": target.id,
^^^^^^^^^```
What am I doing wrong? when I remove judgeRole and moderatorRole overwrites, it works fine.
why guild._fetch_role
also, you should first try getting the role anyway, it should be cached regardless
only fetch when necessary
only other relevant one is - get_role
and it gave the same error
right, tried:
judgeRole = guild.get_role(JudgeRoleID)
same error
what if you print judgeRole
Du weißt eh schon, was bei print raus kommt
so, what did you get?
also, you dont have to typehint everything
we aren't in java, and the return type of that function is already categorychannel
no, thats normal
discord.Role.__str__ is the role name
gotcha
plus excessive typehints make your code less readable IMO
the only place you usually need typehints are function parameters
yeah, got rid of it, it's the only unnecessary typehint in the snippet..
judgeRole = guild.get_role(JudgeRoleID)
moderatorsRole = guild.get_role(ModeratorsID)
# 1v1 Cateogry
perm1v1Challenge = {
guild.default_role: discord.PermissionOverwrite(send_messages=False, view_channel=False),
judgeRole: discord.PermissionOverwrite(read_messages=True, send_messages=True, view_channel=True),
moderatorsRole: discord.PermissionOverwrite(read_messages=True, send_messages=True, view_channel=True),
guild.me: discord.PermissionOverwrite(read_messages=True, send_messages=True, view_channel=True)}
category1 = await guild.create_category(name="🟢┊Ongoing 1v1 Challenges", overwrites=perm1v1Challenge, position=0)```
Ignoring exception in command setup:
Traceback (most recent call last):
ret = await coro(arg)
^^^^^^^^^^^^^^^
await self.callback(ctx, **kwargs)
category1 = await guild.create_category(name="🟢┊Ongoing 1v1 Challenges", overwrites=perm1v1Challenge, position=0)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
data = await self._create_channel(
^^^^^^^^^^^^^^^^^^^^^
"id": target.id,
^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'id'
ohhh f that's where I messed up
:>
Any function that starts with get_ in Py-cord is retrieving the related object from your bots cache. If the object is not in the bots cache the get_ method will return None. Because of this behavior you should check if the get_x method is None and if it is use the fetch_x method.
Why Is Using fetch_ Without Using get_ First Bad?
The fetch_ method makes a call to the discord API. This API call is unneeded if you already have the information. It will also make your command take longer because it will have to send and than wait for a response from the discord API. It will also contribute to the discord APIs global rate limit of 50 requests per second.
What Is Cache?
The cache is a temporary storage inside your bot. It holds many objects from members to messages. When you restart your bot the cache will be empty. When the cache is full it will delete older objects to make space for the new objects.
Thank you for your time < 3
np
makes sense, noted
I still added it
yeye its good
just to be safe
I have a lot of fetches - would it be considered inefficient?
I do it like that
well, its an unnecessary API call
you can do
guild = client.get_guild or await guild.fetch
so I can import it
costs a tiny amount of time and is, as i said, generally unnecessary
if you want to have a thing smaller
have you subclass ur cllent ?
unless your bot is in a huge amount of servers with a billion members, your bot has everything cached
and fetch just ignores cache
yes why?
did the same that's why ;)
I even got both bots sub classed
aight, gotcha!
(discord and twitch bot)
ok N E R D
you are also a nerd so ;3
also, you dont need to tyehint commands.Bot, you can just do self
and it will type hint using ur class
you dont even know if thats a method of their bot subclass
could just be in a util file
if it was in another file, why use commands.Bot and not the good class ? (the one he subclass)
hey all, how can i purge every message in a channel except for the first message that was sent
delete and recreate the channel
set the limit to the message count of the channel - 1
i assume there wont be a lot of messages
if yes, do it like luma said
for channel in guild.channels:
if channel.id == ctx.channel.id:
continue
ur renew here
i cant delete the channel, i need to jus delete all the messages except for the first one, when you say -1, do you mean ctx.channel.purge(limit=-1)?
if there is a lot of message in ur channel
it will be difficult
i dont think there is any limit arg
there probably wont be over 500
you should do so await channel.history(limit=-1) if i understood thooty and then delete all message
but purge can only delete 100 by 100
.history(limit=-1) returns an empty list
lol
then what exactly were u askng me to do
so how do i in a performant manner
uh, do it one time and after that count every message which is getting send. I dont really know a better idea of it
if you gonna do it, you have to go from old to new or you gonna get a error soon
so its not gonna work with new to old if they are to many messages
also, just very generally, what are you trying to achieve
literally just delete every message in a channel except the first one, its sort of like a private channel but the first message is important so i dont want to delete that one but the rest can be deleted
yea i got that lol
but like, whats the use case
to just clear out the channel, sorta like how most utils bots have a !purge command
but why do you need to do it so frequently whats the point
I would instead safe the channel settings and delete/create the channel
does there have to be a point...? i want it bc its a convenience lmao, easier to run a command over hand deleting annoying msgs
knowing the actual point usually helps people find solutions for their odd problems
well there you have it, the only solution i need is to delete every message except for the first one that was sent in the channel
role.is_integration return None even for the interagration of a bot
is that just me that dont know how to use it or its a bug
What is the rate limit for the route : /channels/{channel_id}/webhooks"
Handled under the bucket "1251652749834194955:None:/channels/{channel_id}/webhooks"
and same how many time can we edti webhooks and in how many time
is there any way get the slash command name from message ?
/profile
like this slash command
ctx.command
Command Permission Decorators: Commands: Shortcut Decorators: Objects: Attributes full_parent_name, qualified_id, qualified_name. Methods@ after_invoke,@ before_invoke,@ error, def get_cooldown_ret...
docs are your friend
or do you mean in an on_message event that catches a slash command interaction
you can still do the same ig
since you can get the context from a message
or that only for prefix ?
well there is message.interaction.data which is a dict of the interaction data the docs dont further specify
well
@bot.event
async def on_message(message: discord.Message):
if message.interaction:
ctx = await bot.get_application_context(message.interaction)
ctx.command.name
ah
didnt test but i dont see why it would not work
you could use on_interaction for it
depends on what they need really :> @ivory beacon
yeah thats true, i jsut continue on my prefix thing
i have to detect this embed and scrap some data
but i can't find any idea
ctx.orignal_message
like title is depend on user pets name
description isn't showing pet isn't prestiged (i mean 0)
no
how to detect the message 😕
why ?
on_message?
here is the problem
yes
its not their bot.
dank memer owner gave me permission
mb
yeah but ctx will not work
i'm talking about something completely different
and.. permission for what lol
ah ok
its not forbidden to literally read what the bot posts lmfao
to use their data...
its literally public
if they didnt want the world to read it they shouldn't publicly post it
i think there no way to get the command name ?
pets care
as i said, maybe this undocumented dict has it
okh wait
print it and check
ok
thanks, got a json data
dict* :)
ahh thanks:)
does it have the command name?
yes
{'user': {'username': 'dipdey', 'public_flags': 4194560, 'id': '833972562210979891', 'global_name': 'D1P', 'discriminator': '0', 'clan': None, 'avatar_decoration_data': {'sku_id': '1154896005045694555', 'asset': 'a_c7e1751e8122f1b475cb3006966fb28c'}, 'avatar': 'f4482aef993c6c6757bf645edb690693'}, 'type': 2, 'name': 'info bot', 'id': '1251860422252826634'}
ofc different command, but it has command name
@sage tendon
what is type ?
type:2 ?
the type of the interaction
there others types of interaction ?
thanks mate
np
Task was destroyed but it is pending!
task: <Task pending name='pycord: on_ready' coro=<Client._run_event() running at /home/container/.local/lib/python3.11/site-packages/discord/client.py:400> wait_for=<Future pending cb=[Task.task_wakeup()]>>
Appear when im loading my but and doing a command, any idea ?
you just "split" your code in a another file
so what would the main file look like
just a regular bot with add_cog() stuff?
That is my main file
I usually use json or yaml
but uh thanks I think I kinda get it now
well, 1 line is missing but yea....
oh also where do the cogs go
a new folder
oh that's nice
you don't need to specify them manually and can even organise them into categories
that one also loads all the sub folders
config.py anyone?
lol my discord didnt scroll down despite me hitting esc and trying to scroll
now it did
wtf
but yea, config.py >>>>>>>>>>>>>>
what?
Nah
