Хочу сделать журнал удалённых сообщений.
Вот код:
import discord
import asyncio
import os
class Deleted(discord.Client):
def __init__(self, client):
self.client = client
async def on_message(self, message):
if message.content.startswith('!editme'):
msg = await message.channel.send('10')
await asyncio.sleep(3.0)
await msg.edit(content='40')
async def on_message_edit(self, before, after):
fmt = '**{0.author}** edited their message:\n{0.content} -> {1.content}'
await before.channel.send(fmt.format(before, after))
def setup(client):
client.add_cog(Deleted(client))
print('Deleted: activated')
Ошибка:
Traceback (most recent call last):
File "C:\Users\volva\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 618, in _load_from_module_spec
setup(self)
File "C:\Users\volva\Desktop\botTest\cogs\deleted.py", line 22, in setup
client.add_cog(Deleted(client))
File "C:\Users\volva\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 505, in add_cog
raise TypeError('cogs must derive from Cog')
TypeError: cogs must derive from Cog
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\volva\Desktop\botTest\bot.py", line 42, in <module>
client.load_extension(f"cogs.{filename[:-3]}")
File "C:\Users\volva\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 678, in load_extension
self._load_from_module_spec(spec, name)
File "C:\Users\volva\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 623, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.deleted' raised an error: TypeError: cogs must derive from Cog
Press any key to continue . . .