#Basic Pycord Help (Quick Questions Only)
1 messages Β· Page 15 of 1
i was more interested in View.children
get_x trys to find the thing in the bots cache, if get_x returns None than use fetch_x
yes, you just need to set it up like this
Here's the persistent example.
ty ty
sus
hey thats all im interested in
How can i take datetime.datetime and output something like In {time} minutes!
Damn
The actual markdown is <t:123:R>
<t:123:R>
where 123 is seconds from epoch
well i was saying if i wanted to convert something like 2022-08-26 13:17:47.949812+00:00 to minutes like in 30 minutes the max it could be is one hour because thats the loop time
Ah ok, the datetime object should have an attribute minutes
nvm
you would need to subtract the datetime object from now, than you could get minutes
which would be a timedelta
^
so this (what u stated above) would not work?
it would
this would not
I think this is better UI becouse it countsdown in realtime
So it would work
yes
I prefer the discord timestamp, to me it is cleaner and more accurate. (Also less calculations for you)
why is my guild.categoeries and channels returns a empty list?
guild != None and i am using it to get category by id [get(guild.categories, id=category_id)]
I'm getting "In 2: Application command names must be unique"
but I'm pretty sure that there's no duplicates
Did you check all the files?
ye
how can i use variables in button label in subclassed buttons?
how to delete/unregister a slash command?
ok nvm it just had to cache for few minutes
my bad
i have a doubt
is there a ratelimit on interactions
like how many interaction can bot take at a time
https://discord.com/developers/docs/interactions/receiving-and-responding#endpoints
The endpoints below are not bound to the application's Global Rate Limit.
there's probably a ratelimit on interactions, but it's completely separate from your other bot ratelimits
So the Bot class has these lines in on_application_command_error
command = context.command
if command and command.has_error_handler():
return
cog = context.cog
if cog and cog.has_error_handler():
return
What do I need to do to essentially turn that into
if command has been handled by a per-cog or per-command error handler:
return
I only want the global error handler to trigger if the error has not been handled already by another error handler
(If this is going to be a long discussion/better suited for its own thread, let me know and I can move it)
this is exactly what it does though
well say i have this (pop is a slash command)
@pop.error
async def on_application_command_error(self,
ctx: ApplicationContext, error: DiscordException
):
if isinstance(error, CommandOnCooldown):
await ctx.respond(
"stuff",
ephemeral=True,
)
return
else:
raise error
right now, if an error such as Forbidden is raised by pop, the bot's error handler ignores it entirely, when ideally it would run through its own ifinstance checks
what about just raise
Just use a global error handler then
well the point is the custom handler should handle specific cases, while the global is a catch-all
basically a backup error handler
Yeah but then what's the point in it going through the isinstance checks?
to give the correct response per error type
because you want specific behaviour...?
I thought by:
if an error such as Forbidden is raised by pop, the bot's error handler ignores it entirely, when ideally it would run through its own ifinstance checks
You meant you wanted it to go through the bot's own checks and dispatch a response
what he means is the custom handler is being used to specifically handle CommandOnCooldown
but if he has a condition for Forbidden in his global handler, it will never be reached because the custom handler is in the way
the global one also has CommandOnCooldown, for other commands that may raise it but don't have their own error handling for that specific error
Oh, so the error handler should be used only for certain errors?
for the command-specific one, yes
you could remove the if command and command.has_error_handler():, but then you could run into multiple error handlers running for 1 error
Isn't there a way to run the bot's error handler manually?
true
Like bot.on_application_command_error(error)
So you can use isinstance to check the error within the command's error handler, and then add an else and run this ^
the same logic would apply, meaning it would do nothing because it detected that there is a per-command handler
no he's right
if you invoke it manually, you can just remove the has_error_handler lines
hm
well
ehhhhh
that would still end up with multiple handlers per error, if the global and per-command handlers both handle CommandOnCooldown
Hold on, why are you using the default error handler anyway?
as in, he wants to use the has_error_handler logic in their global handler
If you want the same behavior as it from within the command's error handler, then in the else just write:
print(f"Ignoring exception in command {context.command}:", file=sys.stderr)
traceback.print_exception(type(exception), exception, exception.__traceback__, file=sys.stderr)
Oh
I don't want to copy-paste the entire logic of a global error handler each time that I want to have a per-command handler :/
how about you add a param called smthn like check_handler, and set default to True, but pass False in the else for the command error handler so it skips checking whether there is already an error handler for the command
elaborate
maybe we should allow users to return True/False if an error was handled
and then override how they're dispatched
I'm surprised that a solution doesn't already exist for this, I feel like it is a commonly used thing
Here's a code example:
async def on_application_command_error(ctx, error, check_handler=True):
if check_handler:
# Perform the logic necessary to check whether the command already has its own error handler
...
# Handle the error
...
@pop.error
async def pop_error(ctx, error):
if isinstance(error, ErrorType):
# Handle the error
...
else:
await on_application_command_error(ctx, error, check_handler=False)
oh that's true
you can mess with the global handlers args as long as you make them optional
hmm
that'd still fail in theory though py finally: ctx.bot.dispatch("application_command_error", ctx, error) so global would run anyway with check=True
Oh that's smart

this works!
thanks :D
how does variables work in pycord like for example economy system vars idk
Is there a way to get the number of users in a guild without intents?
???
tyy
You're welcome!
I'm trying to use the new SlashCommand.mention via ctx.command.mention. I get this output:
</character image upload:None>
Is this expected? I assumed it would look something similar to other mentions.
i think this is a problem with parent commands
Ah, you mean it doesn't work with slash command groups/subcommands?
Before you try to help me, let me just tell you. I do not know much about reaction events.
I've been trying to make a thing that if someone reacts to the bot's message with a certain reaction it will do something. I've been trying to get this done using the on_raw_reaction_add event. When I try to get the message(to check if the message author is the bot) it returns None. I'm trying to do it using self.bot.get_message since I would have to make like 3 API calls if I was going to do it using fetch_message
all command.mention does is format it into a string but if the command has a parent then it doesn't work for some reason
What could I do?
Gotcha. That's a shame. Thanks
you could upload the issue to the repo
cuz idk if its intended behavior
you get the msg and if its not found you fetch it
I'll be honest, I figured it was a Discord issue, lol
I tried, doesn't work.
message returns none for messages sent after the bots restart
So I'm running through the debugger. cmd.parent gives me character image as expected. cmd.parent.id is still None. Bringing it further back to cmd.parent.parent gives character, but cmd.parent.parent.id is also None
And SlashCommandGroup has no mention attribute
the id on the top level command should be set from me experience
Can anyone now help me with how I would actually do it? Is this how?py if message.author.id == self.bot.user.id: if message.emoji == "emoji unicode here": print("Someone has reacted to the bot using the emoji")
although I haven't actually touched the groups with get_command because it doesn't seem to work

looks right to me
k ill test it out
Doesn't work sadly
no errors aswell
Here's my whole code: py @commands.Cog.listener() async def on_raw_reaction_add(self, payload): message = self.bot.get_message(payload.message_id) if message is None: channel = self.bot.get_channel(payload.channel_id) message = await channel.fetch_message(payload.message_id) if message.author.id == self.bot.user.id: if message.emoji == "π": await message.reply("Test")
hmm, i'll try to print message.emoji
oh yeah im dumb
``` this messes it up
I did a print before it, it prints out. The prints inside that do not
Seems out, both the values are different
oh wait! It's not a bot's message I'm testing it on my own message, sorry lol
Do I need to get the emoji object and compare it to that? The emoji doesn't seem to be equal.
i use db for storing user/guild information
ok
Can anyone help me? The emoji seems to be the same. I'm getting \π as a print and I'm doing:
if payload.emoji == "π":
print("test")```
Hey. How can i lock all commands in a Cog to a specific Channel Category with @before_invoke
before_invoke takes a ctx parameter you can use, but you should ideally be using checks for this anyway
https://docs.pycord.dev/en/master/ext/commands/api.html#checks
??
payload.emoji isn't a string
The custom or unicode emoji being used.
Type:
PartialEmoji
https://docs.pycord.dev/en/master/api.html#discord.PartialEmoji
read the link there and you'll see
I literally have..
Thank you!!
can i catch which check failed?
avatar.url?
no i mean i have a check function which checks if the command used in a specific category
to catch which check failed if i have multiple
different checks raise different variants of CheckFailure; e.g. has_role raises MissingRole, has_permissions raises MissingPermissions and so on
you can see all of them at https://docs.pycord.dev/en/master/ext/commands/api.html#checks
Don't ask to ask
k.
https://github.com/Pycord-Development/pycord/blob/master/examples/wait_for_event.py#L14
is this example up to date? line 38
examples/wait_for_event.py line 14
async def on_ready():```
One message removed from a suspended account.
no
works for me on 2.1.1
(waiting for timeout was the issue for you?)
yeah the timeout error
I have to switch to 2.1.1?
what version are you on now?
2.0.1
yeah, I would upgrade, no downside. Not sure why it does not work on that version
are there any changes needed to make on upgrading?
There are not any breaking changes mentioned in the update
thanks for the summarised info, I don't always know what the new versions are all about (probably bc I don't use the features that are broken)
π
same error
Well, than i think it must have something to do with the interpreter or something.
You are using the imports and slash command exactly how theyare in the example correct?
yup
and with a check that does a comparision like:
def check_team_category(ctx):
return ctx.channel.category_id == TEAM_CAT_ID or ctx.channel.category_id == LOG_CAT_ID
if you made a custom check then it'll be CheckFailure
@bot.slash_command(name="guess", description="Guess a number between 1 and 10!")
async def guess_number(ctx: discord.ApplicationContext):
await ctx.respond("Type in your number. *(It should be between 1 and 10)*")
def is_valid_guess(m: discord.Message):
# This function checks three things at once:
# - The author of the message we've received via
# the wait_for is the same as command author.
# - The content of the message is a digit.
# - The digit received is within the range of 1-10.
# If any one of these checks fail, we ignore this message.
return m.author == ctx.author and m.content.isdigit() and 1 <= int(m.content) <= 10
answer = random.randint(1, 10)
try:
guess: discord.Message = await bot.wait_for("message", check=is_valid_guess, timeout=5.0)
except asyncio.TimeoutError:
return await ctx.send_followup(f"Sorry, you took too long it was {answer}.")
if int(guess.content) == answer:
await guess.reply("You are right!", mention_author=True)
else:
await guess.reply(f"Oops. It is actually {answer}.", mention_author=True)
Python 3.8 or greater?
I did the same when testing
does the timeout thing work?
yes, it sends the "sorry you took to long" message
can you show the full traceback
that's the breakpoint of the error
ok so without these, it works fine
Well that's great then π
what is it?
I mainly use the breakpoints so I can catch errors however if that gets in the way then I won't be able to catch errors easily (I'm using the wait for ... for applications via DMs)
I have just never seen breakpoints like that
u use VSC? I wonder if u have it use the breakpoints on error that it'll pop up with the same error
No i dont use VSC
How can i make a slash command which output is only visible to the user that invoked the command?
nevermind found it π
Hi, I have a category that makes all the channels created within it restricted to some roles. However, applying permission overwrites to a user will unsync the channel's permission from the category permissions, thus making the channel visible to all roles. How may I sync everything except for the overwrite?
ephemeral=True
How can make slash commands of my bots working in the servers he's in
Wdym
set the guild id in the command?
??
^
Just don't set any guild id
remove the guild ids stuff to get it global
It will not work
?
?tag idw
Saying it doesn't work or asking what's wrong with this code? is not helpful for yourself or others.
Describe what you expect and/or tried (with your code), and what isn't going right.
Please provide any errors you get for optimal assistance.
I removed it now and all of the slash commands desapeared
it takes some time to see them
.
.
if you do it with the guild id you have to restart the bot?
without the guild id?
Yes
that last information I know it can take 1h
Okay but it will work on every server?
yes
Okay tnx
I had it that it was still after hours not at some server and idk why but...
Okay
i made a modal using the example but it keeps telling me File "bot.py", line 1845, in apply modal = test_modal(title="test modal") File "bot.py", line 1818, in __init__ discord.ui.InputText( TypeError: can't multiply sequence by non-int of type 'InputText'
def __init__(self, *args, **kwargs) -> None:
super().__init__(
discord.ui.InputText(
label="test",
style = discord.InputTextStyle.long
),
discord.ui.InputText(
label="test2",
placeholder="test2",
style=discord.InputTextStyle.long
)
*args,
**kwargs,
)
async def callback(self, interaction: discord.Interaction):
await interaction.response.send_message("yes")
@bot.slash_command(name="test")
async def test(ctx: discord.ApplicationContext):
modal = test_modal(title="test modal")
await ctx.send_modal(modal)
missing comma after the second Input Text, line above *args
does anyone know how to make a button that when clicked, deletes the message that the button is attached to?
Like a cancel button
thx
wait it says its an unresolved reference
can you show the callback
can you paste the whole callback function :)
shit that indentation one sec
@discord.ui.button(label="Mark User", style=discord.ButtonStyle.danger, emoji="β", )
async def button_cback(self, button, interaction):
embed = discord.Embed(title="Moderation Action", color=0xff0000)
embed.add_field(name=f"β
{user} marked!", value=reason, inline=False)
await ctx.send(embed=embed)
role = discord.utils.get(ctx.guild.roles, name="marked")
await user.add_roles(role) #add the role marked to the user
await delete_original_message(delay=None)```
there
you use ctx.send in a button?
yea...
also you need interaction.response. in front of the delete_orig...
alr one sec
interaction.delete_original_message()?
shoot, they are right ^ no response
@surreal glade
can you send the code again?
@discord.ui.button(label="Mark User", style=discord.ButtonStyle.danger, emoji="β", )
async def button_cback(self, button, interaction):
embed = discord.Embed(title="Moderation Action", color=0xff0000)
embed.add_field(name=f"β
{user} marked!", value=reason, inline=False)
await ctx.send(embed=embed)
role = discord.utils.get(ctx.guild.roles, name="marked")
await user.add_roles(role) #add the role marked to the user
await interaction.delete_original_message(delay=None)
you have still ctx.send
oh lmao
i swear i replaced that
oh wait i replaced it in the wrong button cback function
@discord.ui.button(label="Mark User", style=discord.ButtonStyle.danger, emoji="β", )
async def button_cback(self, button, interaction):
embed = discord.Embed(title="Moderation Action", color=0xff0000)
embed.add_field(name=f"β
{user} marked!", value=reason, inline=False)
await interaction.response.send_message(embed=embed)
role = discord.utils.get(ctx.guild.roles, name="marked")
await user.add_roles(role) #add the role marked to the user
await interaction.delete_original_message(delay=None)
so here is the code but it is deleting the embed instead of the original message which contains the button
^
Delete the message before you send a new one i guess
Or store the message
how do i do that
message = interaction.original_message I think
^
It feels like a bug the the original_messages changes
ye thats what im saying
Yeah maybe
But I think I use "original_message" as the response sometimes so fixing it would be a breaking change π
@prisma flicker do u have any idea on how to set the character length for a cmd arg, im making a warn command and when it outputs the reason it only outputs the first word
Here's the slash options example.
Does this help β
?tag Timestamps
To make a timestamp you need a unix timestamp. Then, put your time and date into the converter and copy the "Unix Timestamp" (https://www.unixtimestamp.com/) Then to use the timestamp, follow this syntax: <t:COPIED_TIMESTAMP_HERE:FORMAT>
Where it says FORMAT, you can put a few different things:
R: Relative, says "two weeks ago", or "in 5 years"
D: Date, says "July 4, 2021"
T: Time, "11:28:27 AM"
F: Full, "Monday, July 4, 2021 11:28:27 AM"
Example: (note: 1000190514 is Unix time for 11 September 2001)
<t:1000190514:R> -> says 20 years ago
<t:1000190514:D> -> says 11 September 2001
<t:1000190514:T> -> says 12:11:54
<t:1000190514:F> -> says Tuesday, 11 September 2001 12:11
Epoch and unix timestamp converter for developers. Date and time function syntax reference for various programming languages.
OR use this in your code
https://docs.pycord.dev/en/master/api.html?highlight=utils#discord.utils.format_dt
im talking abt normal text cmds
for example if i do %moderate @prisma flicker pycord is the best (pycord is the best being the reason), and i output that message to a channel, it will just print out "pycord" aka the first word
How are you defining the function parameters
async def button_cback(self, button, interaction)
wait
u just said funciton params
here
async def moderate(ctx, user: discord.Member, reason):
You add * before the argument to make it multi-word. Otherwise they only the one word
@full basin gave me this ```diff
- TypeError: can only concatenate str (not "tuple") to str```
Do (..., *, reason: str)
When I did prefix I never had more than ctx and would do it all manually
async def moderate(ctx):
user = ctx.message.mentions[0]
reason = ctx.message.split(" ")[2:]
The point of ext.commands is that you wouldn't have to do it yourself ;-;
Is discord.ext.pages.Paginator not supposed to work with discord.File objects? If not are there any plans to make it accept files as pages?
Traceback (most recent call last):
File "/home/ken/PycharmProjects/ticket_man/venv/lib/python3.10/site-packages/discord/ext/commands/core.py", line 184, in wrapped
ret = await coro(*args, **kwargs)
File "/home/ken/PycharmProjects/ticket_man/ticket_man/bot/cogs/todo.py", line 36, in list
async with get_session as s:
AttributeError: __aenter__
I figure this is a sqlalchemy problem, but wonder if anyone else has gotten this
Well now with slash commands I don't π
I think either d.py had bad examples or people gave me bad advice, or the bot I copied from did it that way so I just kept doing it that way
Or more likely a combination
Can anyone help me? The emoji seems to be the same. I'm getting \π as a print and I'm doing:
if payload.emoji == "π":
print("test")```
I know its not a str but I want to figure out how I can get that object
how does cogs work

a
How do I get an interaction (button or select) that wasn't handled by the bot? Something like "This interaction is no longer available"
read the error
I did, still same error
uh
why won't the image be attached to the embed?
elif command == "finish":
async with ctx.typing():
img = await bld.finish()
img.save(f"build_saves/build_{ctx.author.id}/_build.png")
embed = discord.Embed(title="PAYDAY 2 Builder", colour=discord.Colour.blurple(), description="Build finished!")
embed.set_image(url="attachment://_build.png")
await channel.send(file=discord.File(f"build_saves/build_{ctx.author.id}/_build.png", filename="_build.png"), embed=embed)
storage.is_finished = True```
Here's the persistent example.
how to get categories in a guild
i cant get it throught guild.categories or guild.by_categories()
but i was able to get roles
reinvited bot with admin permission still it is empty
intents = Intents.all()
Is their a method to sync a channels permissions with it's category, I couldn't find Anything in the docs.
i found the problem (it is not in cache) but how to solve it, i want to change permission of a category..
is there a way to fetch a discord user directly without fetching a guild first
https://docs.pycord.dev/en/master/api.html?highlight=guild#discord.Guild.fetch_channels
Sort through to yet the categories
i got category by that but when i do category.text_channels
empty
https://docs.pycord.dev/en/master/api.html?highlight=guild#discord.CategoryChannel.overwrites_for
Get the category permissions like this.
Than set the channels permissions like this
https://docs.pycord.dev/en/master/api.html?highlight=guild#discord.CategoryChannel.set_permissions
https://docs.pycord.dev/en/master/api.html?highlight=get_or_fetch#discord.Bot.get_or_fetch_user
Note this will give a user not a member there is a difference
And there are text channels under it?
yeah
thanks! also my on_guild_join doesn't seem to work
@commands.Cog.listener()
async def on_guild_join(self, guild):
guild = await self.client.fetch_guild(guild.id)
log.info(f"I just joined a server: {guild.id}")
it doesn't even print
Is anything outputed if you use categorie.channels just to test?
From the docs
This requires Intents.guilds to be enabled.
ahh
empty list
[] <class 'discord.channel.CategoryChannel'>
is that a problem? channel.CategoryChannel?
Actually ya know what fetch channels likely updates the cache so after fetching try guild.catagories again
Can you show the code of how you are sgorting out the categories?
is it possible to grey out user commands for some people?
Iirc this id done in the integrations tab
channels = await guild.fetch_channels()
print(guild.categories)
object = get(channels, id=object_id)```
object = category here
wait is object a reserved word π€¦
from db and it is verified
i was being artistic
object_id = task.get("channel_id", None) or task.get("category_id", None)
task is a dictionary that has channel_id or category_id
Would that not get a channel id forst?
First*
Did changing away from object help?
but inside the code
no
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.
no it didnt
Not for "some people" but people without a specific permission yes.
sorry i meant roles or guild perms
@commands.has_guild_permission(ban_members=True)
to check if user has a permission to ban members
i know that one, but then its invisible, but i want to just show it as disabled
I think chesks like has_permissions() would work
Oop I was beat to it
it will create an error and you can reply when that happen
I dont think discord has grayed out commands anymore. They are just hidden now
Sorry I gtg tho.
π

this image is from this server a year ago....discord what have you done
sorry
It's guild_ids=[...]
What owner_guilds contains
DEBUG | ['880368659858616321', ' 956173253469151253']
oh i think this is the issue, it should be int right-
Yes

after fixing that the cmd shows up in other servers too
DEBUG | [880368659858616321, 956173253469151253]
import discord
bot = discord.Bot(debug_guilds=[...]) # specify the guild IDs in debug_guilds
# since global slash commands can take up to an hour to register,
# we need to limit the guilds for testing purposes
@bot.command(description="Sends the bot's latency.") # this decorator makes a slash command
async def ping(ctx): # a slash command will be created with the name "ping"
await ctx.respond(f"Pong! Latency is {bot.latency}")
bot.run("TOKEN")
any help would be appreciated
I would like to have global commands instead of server specific ones tho
from discord.ext import commands?
@slash_command(description="Sends the bot's latency.")
async def ping(ctx: discord.ApplicationContext):
await ctx.respond(f"Pong! Latency is {bot.latency}")
or this i don't know o_o
pip install remove debug_guilds first of all
then get rid of whatever discord package you have and do pip install py-cord
how do i access the value of discord.SelectOption?
Select.values returns only the name of selected items
select.values returns a list with the selected options values
Either the name or value you set through value=...
oh wait, so not the labels?
Returns the label if didn't set a value
i see, thanks a lot!
picrel, as I said, I do not have discord.py or discord (the package) installed
pip install py-cord
oh he's back
I am not offline, just invisible, plus that's an alt
ahh
try running now
uninstall the package
the same error
alright
Do pip freeze and show
.
Yes..
There you go
That's your conflicting library
pip install -u py-cord==2.1.1
the default version that installs seems to be 1.7.3 too
1.7.3 definitely isn't the default, since the latest release on pip is 2.1.1
your pip command is probably running on a version lower than 3.8, in which case instead of pip use py -3.9 -m pip
yeah I did the big goofy
sorted it out rn
yep everything is smooth, except slash commands arent registered
that's weird cause I checked out application.command everywhere
With commands.FlagConverter, how can I make a flag where when the flag is provided in the command (e.g. ?myflagname (no value here)) it returns a specific value, but it doesn't fall back on it's default value as None? so that I can do something like !warn @member ?dm so that when the flag ?dm is provided it is True but when not provided, it's False. not sure if this is possible?
can't you already set the default values
Hey,
can i remove all previous rights of a channel, even from roles rights?
but that seems to go to that when a value of the flag isn't provided
i want to be able to set a value for the flag when the value isn't provided (!warn @member ?dm) but still have a value when the flag itself isn't provided (!warn @member).
im not quite sure what you're going for, but flagconverter is explored in some more detail at https://docs.pycord.dev/en/master/ext/commands/commands.html#flagconverter
you mean completely reset channel permissions?
nop
yes
try https://docs.pycord.dev/en/master/api.html#discord.TextChannel.set_permissions with overwrite=None
oh wait
would this be it or something?
https://docs.pycord.dev/en/master/ext/commands/api.html#discord.ext.commands.Flag.annotation
idk give it a try, i've read all about flagconverter but i've never actually tried it myself
But with this I don't reset all just the member permissions or I specify a role but I want to do this without specifying anything, is that possible?
hold on
try https://docs.pycord.dev/en/master/api.html#discord.TextChannel.edit but with overwrites={}
basically an empty dict so discord would reset them
how can i use variables in button label in subclassed buttons?
but I still have to hand over the role, don't I?
if it's a self variable you can't in the decorator, but what you could try inside the init is self.button_function_name.label="..."
no?
oh lemme try
But he change not the permissions
await channel.set_permissions(overwrites={}) i have get the channel.
so channel is my channel object whats the permissions changed
but he don't change the permissions
channel.edit
^ i linked channel.edit, not set_permissions
ups yeah thanks
I only looked at the old link but not the new one, I thought it was the same, my bad. thanks
nice
hello folks
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: '_MissingSentinel' object has no attribute '_get_overridden_method'
I was going for a fetch avatar from url
this is my code so far
utilitycom = bot.create_group("utility", "Use for userinfo, serverinfo, etc")
@utilitycom.command(description="Get user avatar")
async def av(ctx, member):
member = discord.Member = None
if not member:
member = ctx.message.author
userAvatar = member.avatar_url
await ctx.send(userAvatar)
member = discord.Member = None?
oh
The hell is that?
@commands.slash_command(name="addrole", description="Add a role to a member.")
@commands.has_guild_permissions(manage_roles=True)
@commands.bot_has_guild_permissions(manage_roles=True)
async def _add_role(
self,
ctx: ApplicationContext,
member: Member,
role: Role,
reason: str = None,
) -> None:
await ctx.defer()
await self.manage_role(ctx, member, role, reason, "add_role")
embed = Embed(description=f"{role.mention} added to {member.mention}.")
await ctx.respond(embed=embed)```
can i know why this is not working
it is inside a cog, removerole command is working and bridge command is working
any error?
no
for i in range(4):
buttnum = random.randint(1,100)
@discord.ui.button(label=f"Button{buttnum}", style=discord.ButtonStyle.primary)
async def buttcall(self, button, interaction):
print('augh')```
anyone know a way to put a bunch of buttons using something like this?
this only puts 1 button im assuming because the callback is the same for each one idk how to make different callback for each one tho
How to make auto responder commsnd for multi servers ?
Don't use the decorator, just do button = discord.ui.Button()
@prisma flicker can u trll plz
trll?
How to make auto responder command for multi servers ?
I don't understand the question and please don't ping people who aren't actively helping you. #help-rules
?tag idw
Saying it doesn't work or asking what's wrong with this code? is not helpful for yourself or others.
Describe what you expect and/or tried (with your code), and what isn't going right.
Please provide any errors you get for optimal assistance.
i didnt get any error, and it didnt show up on slash commands, removerole just below it showed and another bridge command also showed..
also update to 2.1.1 or put store=False in load_extension
oh it's not getting registered?
think so
already done
and no errors on startup?
no
can you start a new thread and put the code that's working and the code that isn't there please
u mean new post?
yes
and you already have a thread, don't cross post
if i have a bot running continuously, will msgs from its cache ever get removed? or will the ram usage keep going up?
the default message cache is 1k
ic
so the thing is
im making a giveaway system
i make an object of a custom giveaway class
i store the message object in it while doing so
if the message is removed from cache, it shouldn't be removed from my object right
you'd still have the message object
cool
also
i store these giveaway objects in a list
what the best to discard these x days after ending
del giveaways[1]?
i dont want fifo cause that is based on object creation time
i rather want it to be deleted when smth like 3 days after it ended
yea but how do i handle when they are deleted
how do you get the right giveaway out of the list now?
do you loop through the whole list every time?
idk how this works π
so yes
i can have it in a dict tbh
why don't you use a dict of id to message object?
and then you can just do delkey or whatever
but how do i delay it π
add a function that deletes itself to the object itself and use asyncio.sleep(3days+time_ended) ?
can an object delete itself?
store the ones to delete in a separate list, and have a loop that goes through and deletes them from the dict after 3 days or something
also if i do del gaw_obj will it automatically remove it from the stuff that has references to it?
like lists for eg
ah nice idea
no it just removes that one object
I think
depends if the things in the list are by reference or by value π
that wont use double memory right. storing same obj in 2 lists
how many giveaways are you going to have? lmao
I think you're trying to optimize a little prematurely
was just reading bout it. they say mutable objects are stored by pass to reference
true ngl π
idk why optimization comes into my mind so early
i dont even have the system ready
lmao
I would just get the core system working, and if memory goes up too high then look into optimizing
or, y'know, use a persistent data store
like a database
and then you don't have to keep it all in memory π
hmm good idea
plus if your bot restarts then it would all be gone
i can actually have the giveaway id same as the message id
that would make stuff easier for me
and then you can have a query that runs like every hour delete from giveaways where expiration_date > 3 days ago
you can use an orm
i got this π
ayo you say i can add method to orm objects?
yeah
bro π
i should have done that in my previous project
actually makes sense lmao
dumb me π
aight ty
oh also i have a schedule_end method that does- await asyncio.sleep(duration) and then await self.end()
and i do self.task = asyncio.create_task(self.schedule_end()) in __init__
is there any better alternative
cuz this way i can cancel it too
but i feel it is weird
dk
I like to program defensively "what happens if my bot restarts"
so I would have a task that runs every minute and gets all the giveaways that have ended and end them
i think i can make a thing that does all this stuff again on_ready
cuz now that im using a db
exactly why i thought this was weird
the server im developing this for runs giveaways smaller than a minute. it would be weird to wait another min for results to appear
its a public bot but developed with a specific server in mind
i wonder if any one else would ever add it π€
but thats besides the point π
then I would have a button instead, that only lets you enter if it hasn't ended yet. and if someone tries to enter late the button can end the giveaway too and show the results. it would just call the same method
or run the task more often
I get discord.errors.Forbidden when trying to delete one of the bot's own posts. Is that normal? I thought you could always delete your own posts
hi, how can I verify is the last message of a channel is a button pls? now I have this code
@commands.Cog.listener()
async def on_message(self,message):
if message.channel.id == 1003590390009577493:
if not message.components == discord.button:
channel = await self.bot.fetch_channel(1003590390009577493)
ticket_act = channel.last_message_id
await channel.send(view=button_fermeture_ticket(ticket_act))
but I have this error:
AttributeError: module 'discord' has no attribute 'button'
oh ok thanks bro
Np
hmm
idk ill see tomorrow
almost 2am now
if im doing stuff db based, i should save everything as per id right
How do you make drop downs and buttons persistent?
Here's the persistent example.
what permission is required for this?
I am getting a weird
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access error message now....
Nothing has changed in my bot....
@tranquil pivot ^
Thank you
aight
your bot can't see the channel
or
eh
wait no
are you 100% sure it's that line?
get_channel wont raise that
it will rather return None if a channel with that id isnt found
your bot can't send to that channel
Can I ask why? It has been sending to this channel for many many months and now its not working all of a sudden
how would we know
maybe the perms changed
ultimately you're gonna have to go look at that channel yourself
so um how do I edit a response with ctx? I know that interaction.response.edit() exists but I don't have interaction defined in the command...
oh ok, thx
i just realised, if i store the entered users in a db, does that mean ill have to have a table with all the members the bot has access to? π
cuz yk, many to many field
that's like, literally the point of the members intent
however big your code makes it 
how large would a table with 10k rows be
goes in MB or nah
lets say postgres
i wonder if sqlite can handle this
eh you'll be fine
hmm
also, should i check and add members when i receive them (on ready) or when they have some activity (enter gaws etc)
you can try interaction.edit_original_message, but i think self.view.message.edit may have a higher chance of working
there's no reason to add them separately in on_ready if they never interact with the bot
true
You could try interaction.response.edit_message
and one more thing
the owner says he want this as a requirement
β’ messages (number)
The minimum amount of messages sent by the user after the giveaway started
well
i dont think imma save each and every msg to a db
lets say i skip the content
but still
yeah that's fine
π
on_message, save userid and +1 to it each time i guess
kinda a pain but then the data can be discarded after the gw ends
msg after the giveaway started.
maybe i have a mapping for user and msgcount idk
that's all you need yeah
how do i have this in a db

gonna need another table
foreign key and reverse relation on the gaw table
ig
man too complicated for simple shit
why cant stuff be straightforward
imagine he ends up not using it

can someone know how I can verify if the last message sent on a channel is a button or not pls?
check message.components
that won't work because it won't be None, it'll be an empty list
just do if message.components
well, it's not doing what it should do, I need to verify on a on_message func if the last message is anything else than a button, and send a button if the last message isn't a button
so uhh
have you considered that in on_message, the current message is the last message?
you're already accessing message.channel so you don't need to fetch_channel again
if you want to check if the message doesn't have a button (or any items), then it'd be the opposite; if not message.components
I know but I need the fetch channel for my var "ticket_act" that i'll sent in another class
yeah but my point is that you're checking if the current channel is the same as the one you're fetching
you can completely remove the fetch line and do message.channel.last_message_id
Why would you need to store all of them?
Or any of them
Beyond like the id
yeah it's ttrue but I still have the problem with my buttons
Hey guys. I'm trying to clean up my sessions on the bot's shutdown. I've tried doing so in both a cog_unload and __del__ function in my cogs. The cog_unload function doesn't seem to get called at all and the __del__ function occurs after the event loop is already called thus causing issues with running self.client.loop.create_task(). Just wondering if there is a way I can make this work. Thanks π
:/
what exactly is the issue? i'm not following anymore
Okay
I have a channel where my bot sometimes send ambed.
if it send an ambed, I need to send one button right after.
thats all
if cog_unload isn't firing then something's gone wrong in it py try: self.cog_unload() except Exception: passotherwise, the opposite of the setup(bot) function that resides outside of the cog is teardown(bot)
That is how the library handles shutting down?
so you need to detect if the last message has an embed, not a button?
oh i see now
not really... you said something completely different before
just check message.embeds
no, i see your issue; cog_unload and teardown will only run when using un/reload_extension; shutting down typically bypasses that
it works, thanks buddy
in which case, in your shutdown function you could go through all your cogs and unload them
all good
Ahh that makes sense lol
A little backwards, but if it works, it works π
alternatively, if it's only in one or two cogs you could just use get_cog to access the attributes
but whatever works i suppose
I'll probably go for the first one as quite a few of my cogs use it. Thanks for the help, I'll try that out π
all good
member = discord.Guild.get_member(guild, ctx.author.id)```
this is returning None and im going crazy
if u mean guild_id= then that broke aswell.
no
oh the note
- read the note for
fetch_guildon that page - it should just be
guild.get_member, notdiscord.Guild.get_member
oh yea ofc
you should use bot.get_guild to grab the guild from your cache, which will contain members
ah ok ty
Hey Nelo. Just wondering if there is an event called on the bot's shutdown (equivelant to on_ready, but called on shutdown). I know there is one for on_disconnect, but that's not what I'm looking for here. I can't seem to find a suitable one in the event reference.
I need to be able to call this before the cogs are unloaded and the event loop is shut down.
the wait for event, is there a way to get the user mention on it? Trying to find an event for it, but can't find it unless I'm looking for the wrong one
on_message?
oh that's it? ty
I mean, you said get user mention
Then you want a message.
Then you need to wait_for a message
i don't think so, how are you doing the shutdown?
The bot receives a SIGTERM (^C) and shuts down gracefully since the library is designed to handle it.
INFO:discord.client:Received signal to terminate bot and event loop.
INFO:discord.client:Cleaning up tasks.
INFO:discord.client:Cleaning up after 3 tasks.
INFO:discord.client:All tasks finished cancelling.
INFO:discord.client:Closing the event loop.
<BOT LOOP TERMINATION OCCURS>
<COG UNLOADING OCCURS>
hmmm
The loop terminates before cogs are cleaned up/deleted.
it's caught as a keyboardinterrupt in bot.run
In fact, the only reason why the cogs clean up in the end (triggering the __del__() function is because Python terminates. By then, the loop has long since finished running and you cant really run anything to load/unload them.
mhm
your best bet may be to override _cleanup_loop in client.py py def _cleanup_loop(loop: asyncio.AbstractEventLoop) -> None: try: _cancel_tasks(loop) loop.run_until_complete(loop.shutdown_asyncgens()) finally: _log.info("Closing the event loop.") loop.close()
or if you want i guess you technically don't need to use run at all, use start and implement your own KeyboardInterrupt logic
I'll do it if I have to, but I do wonder why it is necessary in the first place. Is it really that uncommon for people to need to run async logic when the bot shuts down that an on_teardown or on_shutdown event was not created when a on_ready one is?
people doing that likely aren't using run in the first place
If you want more control over the event loop then this function should not be used. Use start() coroutine or connect() + login().
there are other ways to do it, run is just if you don't want to think about anything else
Ahh fair. Still feels like an over-complicated way of handling things when an event could just as easily exist for it. Not here to argue with you of course, but by the same logic on_ready shouldn't exist (barring, of course, reconnects) π€·ββοΈ
Thanks for all the help though. I really appreciate it π
i mean, on_ready exists because it is an event from discord; same with connect and disconnect etc
Are there any dynamic cooldown examples? Cant seem to find it
I said dynamic cooldown.
How do I get modal data in a callback without having to subclass the modal?
All modal examples I can find involve subclassing the modal and handling it that way - this isn't applicable for my use case
modal = discord.ui.Modal()
.
.
.
In Cog/staff.py
class staff(commands.Cog):
def __init__(self, client):
self.client = client
@commands.slash_command(name='mute', description='Mutes <user> for <duration> minutes because of <reason> using discords new timeouts')
@commands.has_guild_permissions(moderate_members=True)
async def mute(ctx, member: discord.Member, duration, reason):
minutes = datetime.timedelta(minutes=int(duration))
await member.timeout_for(minutes, reason=reason)
muteem=discord.embed(title=f"{member.mention} was muted for {minutes} for {reason}", color=0x2F3136)
await ctx.message.delete()
await ctx.respond(embed=muteem)
@commands.slash_command(name='unmute', description='unmuting <user> with <reason> using new discord timeouts')
@commands.has_guild_permissions(moderate_members=True)
async def unmute(ctx, member: discord.Member, reason):
await member.remove_timeout(reason=reason)
unmuteem=discord.Embed(title=f"Unmuted {member.mention}", color=0x2F3136)
await ctx.message.delete()
await ctx.respond(embed=unmuteem)
@commands.slash_command(name="purge", description="Deletes certain amount of messages **ADMIN**")
@commands.has_permissions(administrator=True)
async def (self, ctx, amount=10):
print('Purge enabled')
await ctx.channel.purge(limit=amount + 1)
@commands.slash_command(name="ban", description="Bans specified user | /ban <user> <reason>")
@commands.has_permissions(moderate_members=True)
async def ban(self, ctx, member: discord.Member, *, reason=None):
banem=discord.Embed(title=f"Banned {member.mention} for {reason}", color=0x2F3136 ")
await member.ban(reason=reason)
await ctx.respond(embed=banem)
def setup(client):
client.add_cog(staff(client)))
In main.py
import discord, json, os, random, asyncio, string, time, requests
from discord.ext import commands, tasks
from datetime import datetime
for file in os.listdir('Cog'):
if file.endswith('.py'):
client.load_extension(f'Cog.' + file[:-3])
?
This wont work
Any errorΒ΄s?
No errors
which one doesnΒ΄t work?
can you add store=False to the load_extension()?
Is it cause a command doesn't have self?
That's not what I meant - I'm fine with creating and sending modals, but I'm having difficulty receiving the modal's text input fields in a callback.
...
async def cb(interaction: discord.Interaction):
# parse modal fields somehow
async def some_interaction(interaction: discord.Interaction):
modal = discord.ui.Modal(title="Sample")
modal.add_item(discord.ui.InputText(label="Field"))
modal.callback = cb
await interaction.response.send_modal(modal)
I noticed that interactions have a "data" attribute, but accessing the text input fields from that is very hairy.
you create now the modal in the callback...
?
some_interaction is a placeholder for some event - the cb function is the callback for the modal
Extension 'cogs.owner raised an error: TypeError: Owner.maintenance() got an unexpected keyword argument 'guild_ids'
I believe this is a core library issue
add to the group guild_ids=[id]
but I don't need id
This isn't my code - I just wrote the simplified version for sharing, it's not supposed to be fully functional. I'm trying to access the modal's input text fields from inside the callback, but the only thing passed to the callback is a discord.Interaction.
I want it global
k
This is my callback function that I pass to a modal. I can't subclass the modal because I want to process its data inside another class.
The second line is the only method I have found to access a modal's input data from a callback without subclassing the modal, but it's very hacky.
how do i feckin remove the default help command
bot.remove_command('help')
this is what i tried
where did you put this code
you can also do bot = commands.Bot(prefix,help_command=None) i think
right after i declared the bot = commands.Bot()
alr, imma try that
Pycord's commands extension comes with a built-in help command. In this guide, we will take a look at them as well as learn how to create your own. Let's dive in!
you'd think I havent been racking my brains over the docs since yesterday
but you're wrong
did it work
oh yes
thanks a lot, after I'm done with this I'm gonna make a repo with examples for all basic ass stuff
my whole console if full of this error why it happens and any way to reduce it?
everything works but this
Are people clicking buttons on a view that's not persistent?
well there's your problem
Yea I only need the id, but you can't store them without SQL relations. It's bad practice to store a list without a table (like raw bytes of a python list) and I'm not gonna store it as text and parse it every time
sure but once the giveaway is over you can delete the entries
hey, what api scopes would i need to detect a users activity (listening to song) and is there a scope in pycord to use it
again you're worrying too much π
You only have one view. You can have many components.
yea ill delete the gaw entry and cascade all these on delete
π© yes
i need people to hold me back
what? >_>
i thought of defering the interaction instead and sending a followup if it fails
like this
How to get membercount in pycord?
Guild.members gives you a list of all guild members simply use len() on it and you will get member count
thanks
but IM facing another issue
@bot.slash_command(name = "avatar", description = "Shows the avatar of a user")
async def avatar(ctx, user: discord.Member):
avatar = user.avatar_url
av = discord.Embed(title = "Avatar")
av.set_image(url = f"{avatar}")
ctx.respond(embed = av)
its giving this error
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'Member' object has no attribute 'avatar_url'
avatar.url
oh thanks
what is better? django orm or tortoise orm?
or like which is the best/fastest orm for python
im currently using sqlalchemy orm, but tortoise orm probably would provide an advantage. the reason why im probably not going to switch for my current bots is that i probably have around 1-2K lines of code that use sqlalchemy orm already
Can someone help me?
async with aiohttp.ClientSession() as session:
webhookx = Webhook.from_url('https://discord.com/api/webhooks/1013384645582262293/nDJOCgwRwFc2wy9fR9UEFpMi1T-9OyDhoPgtPAdsg-50dLznA9ULl90Bw--q2ze97XMr/messages/1013385759677501471', session=session)
await webhookx.edit_message(1013385759677501471, content="sal")
Command raised an exception: RuntimeError: Session is closed
can i add a non field element to an orm model?
idk what to call this
what i want to do is, pass my bot object to the orm model
I have defined methods in the model that use it
Hello!
How's everyone today?
I am in need of help.
I am 13 and I just found a thing called "programming" I was lured into it and I was wondering if anyone could help me.
I am using python and I think what I would like to do is statistics.
If anyone could help it would mean my life.
β€οΈ
How would I edit a response after it's sent? I tried storing it in a variable but get the following error.
@slash_command()
async def timer(self, ctx: discord.ApplicationContext):
response = await ctx.respond(embed=discord.Embed(title="Started..."))
print(type(response))
await asyncio.sleep(1)
await response.message.edit(embed=discord.Embed(title="Ended!")) # type: ignore
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'NoneType' object has no attribute 'edit'
ctx.edit?
This might help: https://stackoverflow.com/questions/56738345/could-not-install-packages-due-to-an-environmenterror-could-not-find-a-suitable
uhh i dk what to do
It might be a very bad and hacky idea, but could I misuse the discord.ui.View.interaction_check function and use it as a way to perform a before-callback-invoke hook?
THis might be helpful as well
I think so, you would have to make sure it returns true tho
Hey,
why he say me that code is incorrect when i use random.randint(), but when i use code = ["2112", "1213", "2102"] its that correct? Why?
Code:
self.code = random.randint(1000, 9999)
if self.children[1].value == self.code:
print("Correct..")
else:
print("Incorrect..")
It is kinda hacky but there is no other way to do it within the lib.
What?
https://stackoverflow.com/questions/70094634/oserror-could-not-find-a-suitable-tls-ca-certificate-bundle
You wouldent belive how many times I send a message like that but forget the link 
Yeah fair, I'll see if it works lol
randint returns an int not a string.
Also the random value is highly unlikely to be the value of the button.
Idk how i should fix it im getting this error on my hosting platform and im directly using code from github
it that not working i must be use the code in a list?
what host? do you have access to your user or just the files you add?
It seems the users is missing or has an incorrect file.
you just need to change code into a string before comparison becouse the value is a string
Okay thanks
Ploxhost i use
I have an empty file manager
The code is directly taken from github
Idk where the files could go wrong
They have a great support team, open a ticket with your error.
It is an issue with there setup with the server, should be a simple fix once they see it :)
Okay
So its works but he gives me only one number not four numbers?
self.code = random.randint(1000, 9999)
self.code2 = random.choice(str(self.code))
I want to generate random four numbers and I input those and the bot see its correct or its incorrect.
but he gives me only a number 1 - 9
when i use this in a string
so random.randint will generate 1 random number with 4 digits.
If you want 4 random numbers of 4 digits use list comprehension.
[str(random.randint(1000, 9999)) for x in range(4)]
Does that make sense?
Random choice would choose a random charecter in the string
okay but why range?
it will make a list of 4 items
The code i sent is the same as this
code = []
for x in range(4):
code.append(str(random.randint(1000, 9999)))
Mhmm okay thanks
they told to run this code on my local machine and told its not a host side problem
Traceback (most recent call last):
File "C:\Python310\lib\site-packages\discord\client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "C:\Python310\lib\site-packages\discord\bot.py", line 1025, in on_connect
await self.sync_commands()
File "C:\Python310\lib\site-packages\discord\bot.py", line 685, in sync_commands
await self.http.bulk_upsert_command_permissions(self.user.id, guild_id, guild_cmd_perms)
File "C:\Python310\lib\site-packages\discord\http.py", line 357, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 405 Method Not Allowed (error code: 0): 405: Method Not Allowed
what is this
?tag application.commands
No tag application.commands found.
?tag application.command
No tag application.command found.
?tags command
subcommands, slashcommandmention, commandnoshow, applicationcommands-registration-delay
There are no tags that match your search.
bruh
Basically you are trying to register commands in a guild where you do not have the application.commands scope
Or you are on 2.0.0b7 or older and implementing permissions that are deprecated
also
Ignoring exception in command list clear:
Traceback (most recent call last):
File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 127, in wrapped
ret = await coro(arg)
File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 1202, in _invoke
await command.invoke(ctx)
File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 356, in invoke
await self.prepare(ctx)
File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 278, in prepare
if not await self.can_run(ctx):
File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 373, in can_run
local_check = cog._get_overridden_method(cog.cog_check)
AttributeError: '_MissingSentinel' object has no attribute '_get_overridden_method'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/container/.local/lib/python3.10/site-packages/discord/bot.py", line 997, in invoke_application_command
await ctx.command.invoke(ctx)
File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 359, in invoke
await injected(ctx)
File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 135, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: '_MissingSentinel' object has no attribute '_get_overridden_method'
what is this
see ##1593
is this a latest issue?
which is yet to be solved?
it is solved
- Uninstall discord.py or any other forks of discord.py you might have with the namespace
discord.
python -m pip uninstall discord.py discord -y
2a. Install py-cord
python -m pip install py-cord
2b. Update py-cord
python pip install -U py-cord
Installing other builds:
Note: You need to have git installed. Use !git to find out how to install git.
Updating the module to Alpha (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord
pip install -U git+https://github.com/Pycord-Development/pycord```
git+https://github.com/Pycord-Development/pycord
i just paste this in my requirement.txt file right
yes
nope
Iβm using 2.0.0rc1 and Iβm using a wait_for('message'), and I have a check that is:
def check(m):
return m.author == interaction.user and m.channel == interaction.channel
``` (the context is in a subclassed button callback)
it doesnβt actually return True so I printed `m.channel` and it printed: `Direct message with Unknown User`. Is this a bug with 2.0.0rc1?
#1013311641158438963 then ig
why rc1
I havenβt upgraded to 2.0 because I was experiencing the issue of cogs not throwing errors when loading. But Iβll be upgrading to the latest soon
Yeah just set store=False when loading extensions
not latest per-say, but probably 2.0.1 at least
Yeah I was an idiot and didnβt read the change-log
Is it back to False by default in the latest version?
yeah but 2.1.1 has bugs relating to slash command groups
oh rip
okay bro
master branch also have the issue with slash commands groups
so ##1594 didn't fix it?
still getting the issue on 2.0.1
you're not in a DM, correct?
what is interaction.channel ?
Yeah it prints it correctly
Itβs just m.channel
which is the message it waits for
it might be a discord api issue
:/
The view timed out, and people are still interacting with it, so you're gonna get that error in your logs
I use sqlalchemy+alembic
Got a small question,
I am trying to make a slash command (that worked fine)
But I am also using the on_interaction event and now my slash command gets 'handled' only by the event and not it own function.
Is there a way to 'continue' from the on_interaction that it just finishes the code that is written in the slash_command?
like on_message and on_command. bot.process_application_commands(interaction)
or is it process_application_command
one of them
I will send a screen of my code gimme sec
but yeah since I got the on_interaction event, the slash commands get handled by the event instead of the slash_command
yeah so put this in your on_interaction
whoopppss read it wrong
thanks it works!
np
No the view did not timed out its less than 10s before the view has been started
@prisma flicker
For the fix i thought of defering the interaction
So I canβt check if the channel the command was used in to the new message channel at all?
probably if message_content intent is enabled then it may be availible
Hmm
@prisma flicker sry for pong but help
in the init for the modal, add a bot param
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
np
Define init, set bot as a self variable and then super.init ?
yeah
But how am I to get it when i get use model.get
Ignoring exception in view <FeeAdd timeout=300 children=2> for item <Button style=<ButtonStyle.danger: 4> url=None disabled=True label='Add Fee' emoji=<PartialEmoji animated=False name=':heavy_dollar_sign:' id=None> row=None>:
Traceback (most recent call last):
File "/home/container/bot.py", line 150, in addfee
await interaction.response.send_message("Debt Added to all the **members** in the list :white_check_mark:")
File "/home/container/.local/lib/python3.10/site-packages/discord/interactions.py", line 712, in send_message
await self._locked_response(
File "/home/container/.local/lib/python3.10/site-packages/discord/interactions.py", line 959, in _locked_response
await coro
File "/home/container/.local/lib/python3.10/site-packages/discord/webhook/async_.py", line 211, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/container/.local/lib/python3.10/site-packages/discord/ui/view.py", line 375, in _scheduled_task
await item.callback(interaction)
File "/home/container/bot.py", line 152, in addfee
await interaction.response.defer()
File "/home/container/.local/lib/python3.10/site-packages/discord/interactions.py", line 559, in defer
await self._locked_response(
File "/home/container/.local/lib/python3.10/site-packages/discord/interactions.py", line 959, in _locked_response
await coro
File "/home/container/.local/lib/python3.10/site-packages/discord/webhook/async_.py", line 211, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
man how do i avoid this
i get this everytime
(the function that gets you an object of the class with applied filters and stuff)
