I want to create command what delete reference message if command this answer to message what need delete. I tried use ctx because in docs ctx save attribute message but i get the problem what said css doesn’t have attribute message. My cod:
@bot.slash_command(name='delete_message', description='Для удаления сообщения введите эту команду ответом на сообщение, которое вы хотите удалить.')
async def delete_message(self, ctx):
db = sqlite3.connect(database)
if ctx.message.reference:
a = ctx.message.reference.message_id
ctx.interaction.delete_message(a)
db.commit()
db.close()
problem
Traceback (most recent call last):
File "C:Userszzz03AppDataLocalProgramsPythonPython312Libsite-packagesdisnakeextcommandsslash_core.py", line 728, in invoke
await call_param_func(self.callback, inter, self.cog, **kwargs)
File "C:Userszzz03AppDataLocalProgramsPythonPython312Libsite-packagesdisnakeextcommandsparams.py", line 1083, in call_param_func
return await maybe_coroutine(safe_call, function, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:Userszzz03AppDataLocalProgramsPythonPython312Libsite-packagesdisnakeutils.py", line 567, in maybe_coroutine
return await value
^^^^^^^^^^^
File "D:ProjectsPups_botcogsModeration.py", line 263, in delete_message
if ctx.message.reference:
^^^^^^^^^^^
AttributeError: 'ApplicationCommandInteraction' object has no attribute 'message'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:Userszzz03AppDataLocalProgramsPythonPython312Libsite-packagesdisnakeextcommandsinteraction_bot_base.py", line 1378, in process_application_commands
await app_command.invoke(interaction)
File "C:Userszzz03AppDataLocalProgramsPythonPython312Libsite-packagesdisnakeextcommandsslash_core.py", line 737, in invoke
raise CommandInvokeError(exc) from exc
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'ApplicationCommandInteraction' object has no attribute 'message'
New contributor
Даниил is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.