#General Help
1 messages · Page 30 of 1
I'm so confused now
☕ coffee
@past gate & @slender lintel will u join my server?
@slender lintel can you add me to your repl?
If that's all ok with you?

If not I'll still try my best to troubleshoot from this side
Are you sure the error refer to that line?
it don't shows that
Send full tb
What if
he only sent a snippet when I asked for one
It's actually not that function 💀
I spent the whole time trouble shooting something that worked 💀
daddy
What 💀
will u join my server?
Well. First, can you send the whoooooole entire error
Like everything in red
Convet ctx.guild.id to a string?
What does the syntax error say?
it gives error
On your insert execution
If that was the error I'm folding myself
i sent the full error
Where?
t.
nope still the same error
Oh
also another weird thing is i had to convert ctx.author.id to string even tho in the db its set as bigint but it threw an error saying it expected str but got int
this should instant-register a command for the guild. right?
but it isn't
no wait
um
its for slash commands i think
yea
try debug_guilds?
oh wait, do i need to use @slash.command ?
yee
lemme
Yeah, your using bot command
Try coonvert every int to a string on your db execution
wym
in pgadmin
or
in the code
what's the diff b/w bot and slash and user commands?
I'm trying to help on phone. Lemme get on my pc
Slash commands. /say. Bot commands #say
Bot commands have a command prefix
Like !,#,?
can't we merge them? like the same cmd should get registered on slash cmds too and should even work if someone accesses it using prefix?
str(ctx.author.id),str(ctx.guild.id), str(reason)) like this
help me
bridge.command i think
ids are int -_-
Let me get on my computer.
any docs link pls?
but it trhows an error saying they should be strings.
wioo u join my server?
sure wait
aight
3rd time asked this question
I have no clue. I just use Slash commands for ease-of-use
think abt it, maybe they ignoring cuz theyt dont want to
I can't. I'm at the server limit on my discord
aight! ty
yw
ooh, ty for the help
kk sec
sorry to say but, everyone says this when they don't want and also can't say no
ok fine
IIf u don't
... I'm am helping you lmao. I can't join anymore servers
Like discord literally won't let me
bro 
mines full oh nsfw
@half marsh any idea
No idea
damn
I suggest you create a thread
done
eh what?
how do i make a webhook and store it in a variable
code
i upgraded to 2.0 and now get_cog returns None. i don't see any changes
Its a basic prefix command
send it anyways
also when u defined client
was it
bridge.Bot?
Its commands.command
when u defined client
Its a cog
one sec let me look at the docs
the website in ur bio
class Client(bridge.Bot):
def __init__(self, command_prefix=">>", help_command=None, **options):
super().__init__(command_prefix, help_command, **options)
client = Client(debug_guilds=[ID], case_intensitive=True, intents=discord.Intents.all())
so you are subclassing it lol
you can store that url in a variable then come back to it and make another session
await channel.create_webhook(name="Veno") wait this is how to make it right
ig no
yes
also in a cog you use the decorator @bridge.bridge_command() I believe?
you need a session
kk
you can store the url of that webhook and create another aiohttp session when you want to use it
is it possible to make it with a cmd and storing it
mb im
confused asf
yes, because webhook has a url attribute
@commands.command(aliases=["r", "rt"], description="Restart the Bot")
async def restart(self, ctx):
if ctx.author.id == ID:
await ctx.respond("Restarting...")
os.system("clear")
os.execv(sys.executable, ["python"] + sys.argv)
else:
await ctx.respond("You are not the Owner of the Bot!")
kk
commands.bridge_command
or maybe it's just commands depending on your imports
Its a normal command
so i do a session to create the webhook and another session to store it?
or create and store in only one session
why does every prefix cmd run twice
but slash cmds only once
even in the terminal if i do a prefix cmd and it has an error it prints it twice
but it’s a bridge bot which can only have bridge commands
you can create and store outside of session, but need to use it inside a session
what do i import bridge from
discord.ext.bridge
and how can I use it now? ;3
what is commands
the one that’s a BridgeCommand
a prefix command
is it imported or what
eh, it works on my PI but not on my main system
a normal command with a bridge command bot
that doesn’t work?
i sue bridge commands but prefixed commands run twice idk why
need some help guys.
im trying get user's color from discord.Member attributes (user.color.value), but it returns me all time 0. And i can't get user's status (like online/offline), it returns me "offline" all times. how i can fix it?
all intents is enabled (screenshot)
It does ^^
Did someone managed to make the slash commands work?
yes
it’s been working for like a year
lmao
ikr but I can't find how to make it work tho
on_message_delete() only seems to be called if the bot was online at the time the message was posted. If I post, then start the bot, then delete the message, the event isn't fired.
Is this expected behavior?
Learn all about Slash Commands and how to implement them into your Discord Bot with Pycord!
yes
Disappointing. I assume it's a Discord thing, not a library thing. Thanks
The message isn't cached
yeah, it only receives the event if the message is in the cache
Somebody?..
I didn't know if it was cached or if Discord just sent the whole message
Like it does with context commands (which do work if the bot wasn't online)
Did you enable intents on the developer portal
yes
You may need to fetch the member then receive this info
@slow dome
I just found the note in the documentation. Missed it when I checked the other day.
Is there a way to get an event when a message is deleted, even if it isn't in the cache? I would be fine with just the message id.
you can fetch all messages tbh
so it’s in the cache
Actually, looks like on_raw_message_delete is a thing. Nice
would that not run into the same problem?
Called when a message is deleted. Unlike on_message_delete(), this is called regardless of the message being in the internal message cache or not.
wdym? im getting member object from slash_command option. This is not enough?
I don't need the message contents, so not really. Using the raw event is potentially less efficient, but I can always see if the cached message is there and only do the inefficient option as an edge case
why my logging format and level don't work ?
you have a error to fix
that error isn't a problem the bot is turn on but just logging don't work
an other idea ?
does it still happend after you install the PyNaCl?
wth :/
If I have every time an error some stuff doesnt work
logger = logging.basic .....
logget.info("приколы")
pycord ignore that error because we don't need PyNaCl if we don't use it
isn't it?
nvm...
can you only use InputText with Modals? 👀
At the moment yes
I installed PyNaCl and logging still don't work
PyNaCl has nothing to do with it
it's trouble with logger
is your log stuff just not showing up in the terminal? is that the problem?
showing in wrong format
you probably wanna instead make your own logger, instead of using basicConfig
logger = logging.getLogger("discord") # this creates your logger
log_format = logging.Formatter("[%(asctime)s]:[%(levelname)s:%(name)s]: %(message)s") # sets logger format
console_handler = logging.StreamHandler()
console_handler.setFormatter(log_format)
logger.addHandler(console_handler) # adds console handler to our logger
logger.setLevel(LOG_LEVEL)
handler = logging.FileHandler(filename=LOG_FILE, encoding="utf-8", mode="w")
handler.setFormatter(log_format)
logger.addHandler(handler) # adds filehandler to our logger
this is what I use, probably not perfect or ideal but it works
you can ignore the last few lines about the handler if you don't want to log to a file
It's weird because the logs were working fine 10 minutes ago, I'm still programming my bot, nothing to do with the log and now the logs don't work anymore while the bot is working fine.
do you have logging working in another file?
like are you working in just one file or do you have multiple
multiple
again, not an expert on this, but i'm pretty sure you wanna configure all of your logging stuff in the file you actually run, then you can grab child loggers from the other files
like in that snippet i posted above, the name of the logger is discord so if I have another file, at the top I'll put logger = logging.getLogger("discord.<somenamehere>")
then use logger.info("info message")
fairly sure the name you use for logging.getLogger can be whatever you wanna use, it doesn't do anything special apart from identifying separate loggers in separate files
name is just the name of the logger ?
yes, but I'm fairly sure pycord uses "discord" as their logger name, which is why I make that the root logger name, so it logs all of the bot activity automatically (could be entirely wrong about this, but thats how i understand it)
here that work xD
what is the difference with my other file xD
problem found
it's because I use logging.info() in an imported file before call logging.basicConfig() in my main file
why is my bot running prefixed cmds twice
maybe your on_message event?
no
i defined client as discord.ext.commands.Bot
and in cogs i use commands.command
also yes i have a on_message event but for afk
just for future reference, the method i described will make it a lot easier to organize sub-modules and stuff in the long term
?
can you show us the code 👀
ok thanks
uh
it deleted
its just a normal cmd but it runs twic
every command runc twic
prefixed command*
you can dm it to me, but just fyi, make sure your bot token is hidden
sys:1: RuntimeWarning: coroutine 'Client._run_event' was never awaited
Does anyone know how to fix this? I'm trying to use pycord-ext-ipc but I keep getting this error when I try to start the ipc server.
i have this:
client.load_extension('sql.database')
client.load_extension('cogs.admins')
client.load_extension('cogs.devils')
client.load_extension('cogs.reflex')
client.load_extension('cogs.help')
all are cogs but client.cogs (client = Bot) lists everything except devils and admins . works fine in v1.7.3 but not 2.0
idk where to begin as all have similar inits. admins and devils have cmds but so does help
does pycord 2.0 also include the new slash command permissions?
someone?
can you send the code where you check the status? the color isn't available for bots I think
its like
user: discord.Member
return user.color.value
user object from slash_command option
or ctx.author
status is
user: discord.Member
return user.status
source is still same: slash command
but how are you using this
it's example
im trying get it from attributes
for color its user.color.value
and for status user.status
does this actually return offline or does it not compare when comparing it with the strings of online etc?
it actually returns offline
all times
what I was saying is that user.color probably isn't available to bots (tho I'm not sure)
should be noted in the docs
oh so you're not using a bot but instead an actual account
a discord bot account can't access some values like if a user has nitro etc
and I think the user color is one of those
pretty sure that’s one of the fields it can access
i must use self bot to get data about status? О.о
is the callback when ur bot leave a server called on_guild_leave or on_guild_remove
oh ok then just ignore what I just said 
?tag tias
or read docs 🤔
so.. how i can fix it?
then I have no idea
oh...
cant find em
bloody hell
haven't really touched pycord for the last few months since I waited for the update that was announced today
i have no clue why its happening
took me 20 seconds including searching the link for the docs
https://docs.pycord.dev/en/master/api.html?highlight=on_guild#discord.on_guild_remove
lol
mobile
😔
anyway ty
I'm currently on mobile too
sorry if I'm a lil unfriendly, I'm still hungover
Is there exist other way to get member's status & color?
There's only one way
...
How do I take buttons that I sent as part of a view and get the custom_id of only the first button pressed then disable the view?
What were you expecting?...
Solution to what?
to original problem
No idea what's your problem
.
ok...
oh, wait
it's returns None...
how do i use group commands in cogs
Here's the slash cog groups example.
@frigid elm ^
so i shld have like
@commands.group
async def wwtv
and the cmds will be like
@wtv.command
?
im using prefixed
yeah
but it doesnt work
i have this
@commands.group()
async def setup(ctx):
if ctx.invoked_subcommand is None:
await ctx.reply("That subcommand does not exist")
inside a cog
and
@setup.command()
@commands.has_permissions(manage_guild=True)
async def channel(self,ctx,channel:discord.TextChannel): and some code
but it doesnt show up
LOL
b!rtfm pyc commandgroup
discord.SlashCommandGroup
discord.SlashCommandGroup.checks
discord.SlashCommandGroup.cog
discord.SlashCommandGroup.copy
discord.SlashCommandGroup.create_subgroup
discord.SlashCommandGroup.description
discord.SlashCommandGroup.guild_ids
discord.SlashCommandGroup.name
discord.SlashCommandGroup.parent
discord.SlashCommandGroup.subcommands
also what I was looking for

b!rtfm pyc discord.ext.commands.group
discord.ext.commands.Group
discord.ext.commands.Group.add_check
discord.ext.commands.Group.add_command
discord.ext.commands.Group.after_invoke
discord.ext.commands.Group.before_invoke
discord.ext.commands.Group.can_run
discord.ext.commands.Group.case_insensitive
discord.ext.commands.Group.clean_params
discord.ext.commands.Group.cog_name
discord.ext.commands.Group.command
wait i dont get how to se add_command
do you need to?
idek
I don’t think you do
then how would i make it work
you do prefixgroupname command
yay, I think you should ask discord.py
since pycord doesn’t really uhh use prefixed commands
OHH NVM IM DUMB I DDINT LOAD THE COG
LOL
How to pass Objects using args
and retrieve them too so as to pass those objects to a different function
print(args)
when func(user, target) is called
('@sullen ledge', '@sullen ledge')
is returned
and i cant pass those string to another function cz they accept Member Objects instead of strings
convert the ids to members
but why are we getting ids instead of Member Obects, I am passing user and target bot hof them are Member Objects. So args should look like
(<__main__.Member object at 0x000002E81CF9FD30>, <__main__.Member object at 0x000002E81CF9FCD0>)
instead of this
('@sullen ledge', '@sullen ledge')
check the actual types of the things being passed
The thing is when you dont explicitly mention the type, @user is passed as str, and when you do mention the type, they are passed as that type. For example :
@commands.command()
async def cmd1(self, ctx, user:Member, target:Member):
print(type(user))
print(type(target))
@commands.command()
async def cmd2(self, ctx, user, target):
print(type(user))
print(type(target))
```These are two commands, one specifies the type of user and target parameters, and the other does not.
So when user and target were mentioned to be of type Member, they were received as Member Object. And when they were not linked to any type, they were received as normal str objects of the form <@id>.
Now, since my decorator accepts ctx, and other parameters in *args, I am not able to predefine the type of the variables since i don't know what the variables are. Since, type is not predefined, they are received as str objects instead of Member Objects.
i want to write a decorator that checks whether the command user is lets say, of certain userID.
for example, if I apply my decorator to a command like this
@decorator
async def cmd(self, ctx, user:Member)
It will check whether ctx.author.id == certainID. and if it is, execute the command
a decorator like this would work
def validate_user(func):
async def predicate(user_class, ctx, user:Member):
command_user = ctx.author
data = await mongo_manager.manager.get_user(str(command_user.id))
if data is None:
return await ctx.send("Not Allowed")
await func(user_class, ctx, user)
return predicate
here, await func(user_class, ctx, user) is getting called.
yeah
and since user is Member [explicitly defined]
func call is good and it works
but
I want to be able to apply this decorator to any command with ctx, cz thats what all i need for verfication.
@commands.command()
async def cmd2(self, ctx, id:int)
if i apply my decorator on this command
it wont work, cz i am not passing a user for predicate function instead i am passing an int
to solve that
i thought i wont mention any vars and just accept whatever is being sent, cz i only care about ctx, which is being received as object
so decorator now becomes :
def validate_user(func):
async def predicate(user_class, ctx, *args):
command_user = ctx.author
data = await mongo_manager.manager.get_user(str(command_user.id))
if data is None:
return await ctx.send("Not Allowed")
await func(user_class, ctx, *args)
return predicate
whatever is being received other than ctx, shall be passed as it is, as we dont want to know about them
but now i can't define the type of variables
as *args is of type tuple
so Members will now be received as str
and i wont be able to pass them to original function
so the purpose of your validate_user function is to run checks to see if the author can run the command
def validate_user(func):
async def predicate(user_class, ctx, *args):
# args is a tuple of str
command_user = ctx.author
data = await mongo_manager.manager.get_user(str(command_user.id))
if data is None:
return await ctx.send("Not Allowed")
await func(user_class, ctx, *args) # can't call this as this function accepts only Member object but args is tuple of strs and Members
return predicate
yes
ik i can do if checks
you can make checks as decorators
Hmm
I'm not sure if what you're currently trying would even work on top of a command
Looks fine
it would work
lets say
i dont use the user and target anywhere
then it doen't matter whether they are passes as str or Member
command works in this case
i have tried it
it just agrs members cant have types, and i want type restricted parameters
well I'm not sure if I can do much else here
but I would recommend using the builtin custom checks system
why is this happening in a specific one of my bots only? it works in all my other bots.
Error: py Traceback (most recent call last): File "/home/container/.local/lib/python3.9/site-packages/discord/commands/core.py", line 127, in wrapped ret = await coro(arg) File "/home/container/.local/lib/python3.9/site-packages/discord/commands/core.py", line 851, in _invoke arg = await converter.convert(ctx, arg) TypeError: convert() missing 1 required positional argument: 'argument' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/container/.local/lib/python3.9/site-packages/discord/bot.py", line 992, in invoke_application_command await ctx.command.invoke(ctx) File "/home/container/.local/lib/python3.9/site-packages/discord/commands/core.py", line 358, in invoke await injected(ctx) File "/home/container/.local/lib/python3.9/site-packages/discord/commands/core.py", line 127, in wrapped ret = await coro(arg) File "/home/container/.local/lib/python3.9/site-packages/discord/commands/core.py", line 1171, in _invoke await command.invoke(ctx) File "/home/container/.local/lib/python3.9/site-packages/discord/commands/core.py", line 358, in invoke await injected(ctx) File "/home/container/.local/lib/python3.9/site-packages/discord/commands/core.py", line 135, in wrapped raise ApplicationCommandInvokeError(exc) from exc discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: convert() missing 1 required positional argument: 'argument'
Code: ```py
@slash_command(name="myslashcommand", guild_ids=[...])
@commands.check_any(commands.is_owner(), commands.has_guild_permissions(manage_roles=True), commands.has_guild_permissions(view_audit_log=True))
async def myslashcommand(self, ctx, interval: Option(TimeConverter, description="(e.g. 1h, 1m, 1d, 12h)"), channel: Option(discord.TextChannel)):
stuff
MY TIMECONVERTER CLASS BEING IMPORTED
class TimeConverter(commands.Converter):
async def convert(self, ctx, argument):
args = argument.lower()
matches = re.findall(time_regex, args)
time = 0
for v, k in matches:
try:
time += time_dict[k]*float(v)
except KeyError:
raise commands.BadArgument("{} is an invalid time-key! h/m/s/d are valid!".format(k))
except ValueError:
raise commands.BadArgument("{} is not a number!".format(v))
return round(time)```
im on 2.0.0rc1
convert should either be a staticmethod or you should be initializing the converter class
it works in all my other bots on 2.0.0rc1
because rn it's not getting a self param it looks like
.
no
it works in all my other bots
it doesnt make sense
should I just remove self?
or ctx since ctx isnt used
then obviously there's some difference
there isnt
i copied and pasted the class
and the cog
i removed ctx and it works
but the class is different than the others
but whatever
One message removed from a suspended account.
One message removed from a suspended account.
discord.GuildChannel
One message removed from a suspended account.
or specifically, discord.TextChannel
or even discord.VoiceChannel
depending on the situation
One message removed from a suspended account.
One message removed from a suspended account.
yes
One message removed from a suspended account.
How do I create a slash command with the bridge method?
Concept
just slash without prefix
Thanks
Hello, does anyone know what a command to ban people who do not have a specific role would be like?
Iterate through your guild member and check if they have the role
yes but failed to get the list of users
members intent
? I don't speak English I don't understand many things
could it be clearer?
simplest I could put it
how would be the command line to get the list of users on the server?
or users who watch a channel
I have one question: using pagination, if I go to the second page for example,is the embed switching to second page for everyone or am I just seeing the second page?
One quick question I was trying to setup pycord using the guide but got this error?
could you send a screenshot of your pip list
it updates server-sided, not client-sided, so yes, everyone sees when the paginator moves to a new embed
is that all?
yes
odd, what command are you using to install?
pip install py-cord
hm, are you sure there's no issues with your venv?
i.e. are you installing packages in the right place
im pretty sure its fine i just reinstalled my pycharm and updated my anaconda
well, sorta grasping at straws here, its the only thing i can think of that would explain that error besides namespace conflicts and wrong version
discord.Client works but doesn't work with slash commands
that's intended behavior, client is only meant for handling gateway events, etc.
ye i was just bringing that up because i dont think its the name thats the problem
can you try using commands.Bot and create a slash command?
my only real guess is somehow your install is corrupted/missing files or data
how :0
commands.Bot would be in discord.ext.commands but that indicates that you're missing discord.commands which is where slash command code is held
can you try doing
pip uninstall py-cord
pip install py-cord==2.0.0
it shows you have 2.0.0 which is really confusing but i'm not sure what else would be causing that, seems more like you're on 1.7.3
same error :9
not sure what else to tell you then besides check your venvs/installations
someone else might be able to help you? maybe idk
One message removed from a suspended account.
lmao wtf
uh do pip freeze real quick
do u want a screenshot?
yeah
use https://docs.pycord.dev/en/master/api.html#discord.Member.history to your advantage
you can go through and delete each message
it'll be a bit intensive but should work
cant you use checks? like
def check(m):
return if m.author.id == clear_user_id
await channel.purge(limit=limit, check=check)```
that would work on a per channel basis
you'd have to do that for each channel
and who knows how big the amount of messages in that channel could be
o
it'd be a lot more intensive than just using Member.history
ok that makes sense
it still doesnt work 😔
One message removed from a suspended account.
One message removed from a suspended account.
no
even if you were gonna do it on a per-channel basis you need to actually check the message attributes, not checking in
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
?tag tias
gave me an error
can I use defer on a paginator?
ig conda is just being horrible @gilded widget
i switched over to pycharm inbuilt venv and it worked lmfao
how to limit commands to certain roles/people with certain permissions?
you can use the @commands.has_permissions() and @commands.has_role() decorators
b!rtfm pyc commands.has_
discord.ext.commands.has_any_role
discord.ext.commands.has_guild_permissions
discord.ext.commands.has_permissions
discord.ext.commands.has_role
discord.ext.commands.bot_has_any_role
discord.ext.commands.bot_has_guild_permissions
discord.ext.commands.bot_has_permissions
discord.ext.commands.bot_has_role
discord.ext.commands.Group.has_error_handler
discord.commands.permissions.has_any_role
ah thanks
anyone know how to change the status of a bot
and how to add slash commands to a server (mine only go to the debug server i listed)
b!rtfm pyc change_presence
I know this isn't a pycord question, but probably an easy answer. What is the style of channel used here in Help called? (With separate threads inside the channel.) I don't know what to search for to learn about it, lol.
forum channel
Thanks. :)
im using await interaction.delete_original_message() and getting discord.errors.NotFound: 404 Not Found (error code: 10015): Unknown Webhook
Is it possible to make Paginator buttons look like this? Select is just a normal button which will call a function.
Select btn can be appended after the arrow buttons but that looks ugly
Documentation says it happens when the message is deleted already
Make sure thats not the case
Try fetching the InteractionMessage using original_message() and then calling delete on that.
ok
is this right?
msg = interaction.original_message()
await msg.delete()``` i did it and got an error
how do i get my uptime as a unix timestamp?
await interaction.original_message()
okay ill try that
discord.errors.NotFound: 404 Not Found (error code: 10015): Unknown Webhook
Hmm
same error as before with the interaction.delete_original_message()
i defered it and it worked!

very werid
does anyone know how to make buttons only executeable by the interaction author
like make it disabled for everyone except
them
you can simply compare interaction user id with author's id
you can get author's id by passing it through view as and argument
for example
@slender lintel
Ye ik that
But I’m not sure how to make the buttons only disabled for certain
People
you can't make them disabled
Oh
you can make them not respond to certain people
👍🏻
Hello everyone, I have an question. Does everyone having the issue that the script don't find the interaction and do not defer it? It hapens some time for me
Anyone an idea where this is coming from? Timeout in autocomplete?
Task exception was never retrieved
future: <Task finished name='Task-45055' coro=<ApplicationCommandMixin.on_application_command_auto_complete.<locals>.callback() done, defined at /var/discord/venv/lib/python3.9/site-packages/discord/bot.py:739> exception=NotFound('404 Not Found (error c
ode: 10062): Unknown interaction')>
Traceback (most recent call last):
File "/var/discord/venv/lib/python3.9/site-packages/discord/bot.py", line 742, in callback
return await command.invoke_autocomplete_callback(ctx)
File "/var/discord/venv/lib/python3.9/site-packages/discord/commands/core.py", line 1177, in invoke_autocomplete_callback
await command.invoke_autocomplete_callback(ctx)
File "/var/discord/venv/lib/python3.9/site-packages/discord/commands/core.py", line 1177, in invoke_autocomplete_callback
await command.invoke_autocomplete_callback(ctx)
File "/var/discord/venv/lib/python3.9/site-packages/discord/commands/core.py", line 905, in invoke_autocomplete_callback
return await ctx.interaction.response.send_autocomplete_result(choices=choices)
File "/var/discord/venv/lib/python3.9/site-packages/discord/interactions.py", line 890, in send_autocomplete_result
await self._locked_response(
File "/var/discord/venv/lib/python3.9/site-packages/discord/interactions.py", line 956, in _locked_response
await coro
File "/var/discord/venv/lib/python3.9/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
Какая у тебя версия библиотеки?
это канал помощи, какая разница
я же пытаюсь тебе помочь, а не намеренно использую руссиянский по приколу

если повторяется, мб в коде проблема, гдето застряёт мб
не может быть, у меня выполняется await ctx.defer в первую очередь
обычно при запуске бота есть промежуток, в который команды еще не работают
я жду полной готовности
попробуй вывести в консоль чтото по ходу выполнения команды
в начале, середине и конце
дебагни короче
у меян брейкпойнты стоят
ну и где ломается
катчит ток при await ctx.defer()
дискорд крут
согл
убери дефер, думаю обычного времени достаточно
@user.command()
async def stats(self, ctx: discord.ApplicationContext, member: Option(discord.User, 'Specify an user')):
member = ctx.author if member is None else member
await ctx.defer()
cur = plugins.CONNECTION.cursor()
cur.execute('''
SELECT * FROM player WHERE user_id=%s;
''', (member.id,))
fetch = cur.fetchone()
ytf
неа
тогда вообще не выводит
у меня psql
ладн
есть еще идеи, или в issues кидать
есть какая то закономерность в появлении этой штуки
у меня дедлайн сегодня
после получения опыта вроде
и
думаешь?
можно сказать после апдейта базы
дефер вообще странно работает, я обычно стараюсь его не использовать
но это уже дискорд так накодил
кидать баг репорт?
дису или библе
окей
запутанно все

согл
ну для начала не юзать sync бд в async проекте
есть черепашка, ее сам овнер либы юзает
может успеешь переписать основной функционал)
там не сложно вообще, даже можно вроде напрямую команды давать
у меня еще пол проекта не завершено, я 10 дней хуи пинал)
я могу попросить еще время дать
да-да
если это искючить
или баг в либе, или дискорДик молодец
можешь попробывать подать репорт в гитхаб опять же к челам сюда
но хз
bump
how
import calendar
import time
from datetime import datetime
dt = datetime(2017, 12, 31)
print(time.mktime(dt.timetuple()))
print(calendar.timegm(dt.timetuple()))
this is the example given but how do I change dt = … to the time when my bot starts is?
mhm, second
you should make an variable and record a time here whenever bot starts... may be
it should work
im not sure if there is other way
there may be
then you just current_time - start_time
import discord
from discord.ui import Select, View
from discord.ext import commands
from discord.commands import SlashCommand
client = commands.Bot()
class help(commands.Cog):
def __init__(self, client):
self.client = client
@client.slash_command(name="help", description="Opens a select menu based on helping.")
async def menu(self, ctx):
select = Select(
placeholder="Choose your help category:",
options=[
discord.SelectOption(
label="Moderation",
emoji="🔨",
description="Shows all the available moderation commands.",
),
discord.SelectOption(
label="Fun",
emoji="🐸",
description="Shows all the available fun commands."
),
discord.SelectOption(
label="Misc",
description="Shows all the available misc commands."
)
]
)
async def menu_callback(interaction):
if select.values[0] == "Moderation":
embed = discord.Embed(title="Moderation", description="""
:white_small_square: `Ban`, Bans a user from the server, (/ban)
:white_small_square: `Clear`, Clears a selected amount messages from a channel, (/clear)
:white_small_square: `Purge`, Clears a selected amount messages from a channel, (/clear)
:white_small_square: `Kick`, Kicks a user from the server, (/kick)
:white_small_square: `Unban`, Unbans a user from the server, (/unban), copy there id!""")
elif select.values[0] == "Fun":
embed = discord.Embed(title="Fun", description="""
:white_small_square: `Ban`, Bans a user from the server, (/ban)
:white_small_square: `clear`, Clears up too 1000 messages from a channel, (/purge)
:white_small_square: `Kick`, Kicks a user from the server, (/kick)
:white_small_square: `Unban`, Unbans a user from the server, (/unban), copy there id!""")
elif select.values[0] == "Misc":
embed = discord.Embed(title="Misc", description="""
:white_small_square: `multiply`, Multiples two numbers together, (/multi)
:white_small_square: `Selectmenu`, Provides information on a selected mod menu, (/selectmenu)
:white_small_square: `Help`, Show this embed, (/help)
:white_small_square: `Server Info`, Sends information about the server, (/server_info)
""")
await interaction.response.send_message(embed=embed, ephemeral=True)
select.callback = menu_callback
view = View()
view.add_item(select)
await ctx.respond("Choose what category u need help with: ", view=view)
def setup(client):
client.add_cog(help(client))
so i have this shity help command but i wanna make a command that looks like this any one know how i can?
i wanna make it look like that
Code:
@commands.Cog.listener()
async def on_ready():
print(f"{self.bot.user} is online & functioning!")
global startTime
startTime = time.time()
Error:
Ignoring exception in on_ready
Traceback (most recent call last):
File "/home/container/.local/lib/python3.9/site-packages/discord/client.py", line 382, in _run_event
await coro(*args, **kwargs)
TypeError: on_ready() takes 0 positional arguments but 1 was given
confused
You don't seem to be using a class, and if you are, you need to use self
you need a (self)
ah ok ty both
The embed shown here is using fields. The three blocks are inline with each other and the value has a code block which is why it's darker
Check out the docs and experiment a bit
is a proper implementation of BridgeOptions being considered or being worked on or is it already done in the latest commit?
async def cmd(self, ctx):
async def select_callback(self):
# do stuff
paginator.clear_items()
button = Button(label="Click ME")
button.callback = select_callback
paginator = Paginator(pages)
await paginator.send(ctx)
this is not working
paginator items are still there even after pressing the button
i have a little error with PyNaCl, can someone help me pls? i installed, uninstalled, changed version etc
can't get it working
Did you installed something?
code? error trace?
not a code related issue
i do pip install PyNaCl and it installs
nope
right..
but it's not working
not working as in?
shows the generic, Needs the lib for voice
maybe reinstalling pycord /w voice would help
# Linux/macOS
python3 -m pip install -U "py-cord[voice]"
# Windows
py -3 -m pip install -U py-cord[voice]```
Please don’t ping other members
ok
I ran into the same issue. It seems to be due to this commit:
https://github.com/Pycord-Development/pycord/commit/33a0a2522f11e63c6d6e2ae84bd2dfc754b36d1f#diff-9a360fa14dc0981d2044cee070fd0707bbd71d0dc49bae324f230722baffb51eL847
Previously, a "self" was given to converters:
arg = await converter.convert(converter, ctx, arg)
But now, it is either instantiated if it is an instance of type and the convert is called on the created instance, or it is used just as if it was static method. But isinstance(converter, Converter) returns True even if converter is actually a class, that is a subclass of Converter. 🤔 Hence, @midnight cedar s suggestion to either instatiate the class or make it a static method should work.
But also yes, the old behaviour was broken by that commit.
I got it fixed
Please don’t ping me randomly
That was not randomly. I read your conversation when I was searching for a fix myself, and it seemed as if you would be interested in that info. Sorry for disturbing...
Chill they were just trying to help lol
Oh sorry I didn’t see the message you were replying to
Oh so it was the commit? Because I was confused because I copied and pasted the same code and I guess I reinstalled on the commit that wasn’t working.
https://mystb.in/CropSpecifyVanilla.python theres a problem in this that wont make me load the cog
specify problem?
i have mod.py cog but it wont load and it doesnt give me any error, i tried pasting the code in another cog but it wont load that asw, so there's something in that code that blocks the bot to load the cog
kinda confusing
how are you loading your cog
await bot.wait_until_ready()
for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
bot.load_extension(f"cogs.{filename[:-3]}")
i tried the hello command from the github example https://github.com/Pycord-Development/pycord/blob/master/examples/app_commands/slash_options.py
it doesnt work, has anything changed to options in slash commands and it didnt get updated?
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/slash_options.py at master · Pycord-Development/pycord
define doesn't work
wdym by define?
what do you mean it doesn't work. what doesn't work
oh i see 😄 got that wrong. So when i try to use the command /hello it doesnt show me any options to fill in
if you try and use the command, what would happen
two quick screenshots
i renamed the command to build, nothing else changed
so it doesnt give me the options to fill in and just uses the default values
try using the guide example
?tag guide
Learn all about Slash Commands and how to implement them into your Discord Bot with Pycord!
thank you, i found the solution for the first one too, the second one works but looks different of course
https://mystb.in/CreaturesCalmVacancies.python somehow it blocks the cog
ive been trying to figure it out for hours
but i cant see any problem
nd it gives no erros
errors*
did you add the cog setup function
def setup(bot):
bot.add_cog(CogName(bot))
yeah, they did
oh
@forest talon ^ that’s their full code
ah ty
yes i did
its a weird ass problem
idek what to do anymore
did you fix the error on line 124
embed = discord.Embed(color=discord.Color.from_rgb(13,99,143),title=f"{message_before.author.name} has edited a message・{message_after.author.id}",title="Message edited")
you put two titles
it worked after i changed one of them to description=
lmao
ure my savior
it gave me an error though
a basic error took me 4 hours
not to em
me
u dont understand u just saved me
omg
lol np
How do I make an auto response to a message without a prefix
is their any way when using autocompletion for command options (because the choices limit is too low) to validate the input before sending the command?
listen for on_message(message), same way you did for on_message_delete
make sure to process commands afterwards too, just in case
await bot.process_commands(message)
How come this is erroring when i have a status loop that loops every 13 seconds. It errors like this after a while tho
future: <Task finished name='Task-1' coro=<ch_pr() done, defined at /home/container/main.py:78> exception=ConnectionResetError('Cannot write to closing transport')>
Traceback (most recent call last):
File "/home/container/main.py", line 94, in ch_pr
await set_status_as_guilds()
File "/home/container/main.py", line 75, in set_status_as_guilds
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name=f"tickets for {len(client.guilds)} servers"))
File "/home/container/.local/lib/python3.9/site-packages/discord/client.py", line 1179, in change_presence
await self.ws.change_presence(activity=activity, status=status_str)
File "/home/container/.local/lib/python3.9/site-packages/discord/gateway.py", line 667, in change_presence
await self.send(sent)
File "/home/container/.local/lib/python3.9/site-packages/discord/gateway.py", line 627, in send
await self.socket.send_str(data)
File "/home/container/.local/lib/python3.9/site-packages/aiohttp/client_ws.py", line 150, in send_str
await self._writer.send(data, binary=False, compress=compress)
File "/home/container/.local/lib/python3.9/site-packages/aiohttp/http_websocket.py", line 687, in send
await self._send_frame(message, WSMsgType.TEXT, compress)
File "/home/container/.local/lib/python3.9/site-packages/aiohttp/http_websocket.py", line 598, in _send_frame
raise ConnectionResetError("Cannot write to closing transport")
ConnectionResetError: Cannot write to closing transport```
and it has nothing to do with the code
are you on the latest version of pycord and aiohttp
it works when i run it
yes
well no it errors after a certain time
not right away
like a few hours
i don't think so, in the docs it mentions that validation is not available when using an option's autocomplete
if that's what you meant
Yeah I just thought that there is maybe a workaround but I guess the workaround is just to throw an error message if the user uses an item not included in the list. Straight up validation would be way cooler though
How do you put a saved file into an embed because it only takes url?
@slender lintel check this one, worked for me
https://stackoverflow.com/questions/63422822/attach-a-file-in-an-embed-discord-py
I am currently writing a discord bot with discord.py Rewrite and I want to attach an image onto an embed but I can't figure it out.
import discord
from discord.ext import commands
from discord import
yeah it would
got rate limited but will try
How can I delete dropdowns after I've interacted with them? (as in, in the callback of the Select view)
Code:
@bot.event
async def on_message(ctx, message):
if message.content.lower() == f"<@!{bot.user.id}>" or message.content.lower() == f"<@{bot.user.id}>":
await ctx.reply("testinggg")
Error:
Ignoring exception in on_message
Traceback (most recent call last):
File "/home/container/.local/lib/python3.9/site-packages/discord/client.py", line 382, in _run_event
await coro(*args, **kwargs)
TypeError: on_message() missing 1 required positional argument: 'message'
if anyone could help then I’d appreciate it, I’m quite confused 
Events don't take ctx
Remove the view by doing view=None
so all I need is message?
fixed
would len(self.bot.member_count) return the amount of members from all guilds my bot is in?
No, that would be len(self.bot.users)
b!rtfm bot.users
I couldn't find a documentation with the name bot.users! Maybe you used to command wrong? Correct Usage: <prefix>rtfm <docs> [<term>] (eg. b!rtfm py cool)
List of Documentations you can search:
python
pycord
discord.py
yarsaw
nextcord
disnake
b!rtfm pyc bot.users
how do i get the "everyone" role
i want to something like this
await voice_channel.set_permissions(everyone_role, connect=False)
but how do I get the "everyone" role of a guild?
nvm i figured out
it's guild.default_role
Traceback (most recent call last): File "/home/bots/discord/python/Ruby Network/Bot.py", line 4, in <module> from commands.setJoinChannelCommand import setJoinChannelCommand File "/home/bots/discord/python/Ruby Network/commands/setJoinChannelCommand.py", line 10, in <module> class setJoinChannelCommand(commands.Cog): File "/home/bots/discord/python/Ruby Network/commands/setJoinChannelCommand.py", line 16, in setJoinChannelCommand async def setinvitechannel(self, ctx, channel: discord.channel): File "/usr/local/lib/python3.9/dist-packages/discord/commands/core.py", line 1625, in decorator return cls(func, **attrs) File "/usr/local/lib/python3.9/dist-packages/discord/commands/core.py", line 645, in __init__ self.options: List[Option] = self._parse_options(params) File "/usr/local/lib/python3.9/dist-packages/discord/commands/core.py", line 696, in _parse_options option = Option(option) File "/usr/local/lib/python3.9/dist-packages/discord/commands/options.py", line 161, in __init__ raise exc File "/usr/local/lib/python3.9/dist-packages/discord/commands/options.py", line 156, in __init__ _type = SlashCommandOptionType.from_datatype(input_type) File "/usr/local/lib/python3.9/dist-packages/discord/enums.py", line 704, in from_datatype if issubclass(datatype, str): TypeError: issubclass() arg 1 must be a class
class setJoinChannelCommand(commands.Cog):
@slash_command(name="setinvitechannel", description="Setzte den Invite Channel fest!", guild_ids=[923972845124583455])
async def setinvitechannel(self, ctx, channel: discord.channel):
config = ConfigParser()
It's the channel: discord.channel
But what should I write instead?
quick help with a project
eh?
class Enemy(EnemySprite):
def update(self):
global g
g=0
self.rect.y += self.speed
for invader in invaders:
if self.rect.y > win_height:
self.rect.x = randint(80, win_width - 80)
self.rect.y = 0
g=g+1
print(g)
if g==1:
mini_image.fill((255,255,255,0))
window.blit(self.image, (self.rect.x, self.rect.y))
this is the code and the problem is that the g value doesnt update every time the if condition happening
it stills at value of 1
discord.TextChannel
Thx, how can i create a directory/file if not exists?
with open("resources/config.ini", "w+") as f:
config.write(f)
It says: Application Command raised an exception: FileNotFoundError: [Errno 2] No such file or directory: 'resources/config.ini'
this code
nr = 300
for number in range(nr)
returns TypeError: 'str' object cannot be interpreted as an integer
how do i fix this ?
int(300)
You could just range(300). Whats the point of defining a var
i get the var so it has to be (nr)
cause the var returns a random number
and i need to send that number from 0 to that number
in this case 300
OK then
discord.Channel
does anyone know how i could get the locale field of a interaction via pycord?
I am assuming that you are getting the input as a string. Convert the message to an integer before putting it as a range.
value = "10281212"
for number in range(int(value)):
...
ooh ill try that thanks
full error please
does anyone know how i could get the locale field of a interaction via pycord?
interaction.locale
b!rtfm pyc interaction.locale
thank you
and inside there i can findthe users language
right
@slender lintel please don’t write here additionally if you’ve created a thread. And don’t beg for help in general too afterwards.
It’s all volunteer and we help if we got time.
How would I convert the find1 to a discord.Color type? without having it be a argument
async def test_welcome(self, ctx):
request = mycol.find_one({"key": f"welcColor_{ctx.guild.id}"})
find1 = request["data"]
if ctx.author.guild_permissions.manage_guild:
if mycol.find_one({"key": f"accepted_{ctx.author.id}"}) is not None:
embed = discord.Embed(title="Test",
description="Test",
color=find1)
await ctx.send(embed=embed)
# ....
Nvm, i got it
How can I find an example for unpack_audio
i noticed when using interaction locale it gets the locale from when u execute the command, such as i will do /something in say french and then go to settings and change to spanish then i edit the message to make it get the interaction.locale again it gets the one of the original command locale
how do i set some commands to be only in debug server and some in any server my bot is in?
Or if thats not possible how do i make commands available outside my debug server that is listed
try setting guild_ids in your slash command decorators
do i have to do that every time :z or is there a work around?
you could group your commands
make a section for debug commands
and then you'd only have to pass the guild_ids for that one group
o so u can have one decorator for a group of commands??
hey
i have
class memeView(discord.ui.View):
def __init__(self, lang):
super().__init__(timeout=None)
@discord.ui.button(
label="Next Meme",
style=discord.ButtonStyle.green,
emoji="⏩",
custom_id="submit"
)```
im trying to pass language
to the button
and make label = label
and label will be the translated
text via lang
label = await translate_lang(text, lang=lang)```
easy enough, instead of using the decorator there's 2 other ways to go about it:
class memeView(discord.ui.View):
def __init__(self, lang):
super().__init__(timeout=None)
# whatever lang processing here
button = discord.ui.Button(label=label, ...)
button.callback = your_callback
self.add_item(button)
# your_callback can either be in the view class or defined outside
or, subclass button and allow kwargs in init
if you were to not do the slash command group idea, and minus the syntax errors, yeah
oh yea the missing "
kk
ah i get it thanks
how can i callback it after?
what do you mean?
react to a button click
and then do something
like before i had
@discord.ui.button(
style=discord.ButtonStyle.red,
emoji="🗑️",
custom_id="delete"
)
async def delete(self, button: discord.ui.Button, interaction: discord.Interaction):
await interaction.response.defer()
await interaction.delete_original_message()``` which would when you interact it would delete the message
but when doing add_item im sorta confused
updated my example a bit for that
#list devs
@slash_command(guild_ids=database.owner_guild_ids, name="list-devs")
async def list_devs(self, ctx):
"""Shows bot devs"""
if check.is_dev(ctx.author.id):
num = 0
devs_list = ""
dev_ids = list(database.dev_ids())
for dev_id in dev_ids:
num += 1
dev_mention = f"<@{dev_id}>"
devs_list += f"`{num}.` {dev_mention}\n"
dev_em = discord.Embed(description=devs_list, color=database.theme_color)
dev_em.set_author(name=f"Devs List", icon_url="https://cdn.discordapp.com/emojis/979609228845129738.png?size=96")
await ctx.respond(embed=dev_em)
else:
errorEm = discord.Embed(description=f":error: You are not authorized to use the command.", color=database.error_color)
await ctx.respond(embed=errorEm, ephemeral=True)
^^ Help Me
@slow dome
yes
if i restart the program will it add another response?
cause i udpated my program but it processes the request, but also gives an application did not respond message
Did you use ctx.respond?
Well it will prevent the application didn't respond msg
For interactions always use ctx.respond
ah i see
I think the main problem is its running twice for some reason so id like to prevent that
Or ctx.defer which is similar to ctx.trigger_typing
@deep grail do u have any suggestions abt this? I had a error so i corrected it and restarted the program and then i started getting this
?
Send the code for what's causing teh issue
nothings causing the issue specifically
the program runs fine
i just get two responses
Yeah so that should be fixed with using ctx respond instead of ctx send
kk
The interaction didn't respond error?
yes so i corrected the error that was popping up and restarted the program
and that happened
And it happened again?
yes but it also gave the correct response
it sent the correct response first
Yeah so wasn't it fixed when u replaced ctx.send with ctx.respond?
btw how to make it ephermeral
Becuz what's happening is discord doesn't know ur acknowledging the interaction when u use ctx.send, but with ctx.respond it does and doesn't show the failure msg
ephemeral=True
Yeah
@ornate spade plz Help
Don't ping the admins for help
I think the issue is with u supplying database.owner_guild_ids, check the type of that @slender lintel
Also is the error during cmd registration or when the cmd is run?
when cmd run
Hm
After this line of code every line after this code also shws the same error
How do i get the inviter and the invite url in on_member_join?
@deep grail
No clue
Check the docs
Add random print statements and tell me which line of code causss the error
does anyone know how to do that thing some bots do where their response to slash commands make it look like they're responding to a message
ctx.respond
I have made
https://discordpy.readthedocs.io/en/latest/api.html?highlight=on_member_join#discord.Guild.invites
But I don't quite understand how to get the inviter there. could you help me?




