Вывод снимка экрана Python
Бот дважды запускает одни и те же команды
Ссылка: Main.py:
Код: Выделить всё
# main.py
import os
import asyncio
import dotenv
import discord
from discord.ext import commands
import db
dotenv.load_dotenv("bot.env")
intents = discord.Intents.default()
intents.members = True
intents.message_content = True
intents.guilds = True
b = commands.Bot(command_prefix="!a ", intents=intents)
async def load_cogs():
for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
await b.load_extension(f"cogs.{filename[:-3]}")
print("✅ All cogs loaded")
@b.event
async def on_ready():
print(f"✅ Bot online as {b.user}")
# Check for duplicate commands
all_commands = list(b.commands)
command_names = [cmd.name for cmd in all_commands]
duplicates = [name for name in command_names if command_names.count(name) > 1]
if duplicates:
print(f"🚨 DUPLICATE COMMANDS FOUND: {duplicates}")
else:
print(f"✅ No duplicate commands. Total: {len(all_commands)}")
# List all commands
for cmd in all_commands:
print(f" - {cmd.name} (cog: {cmd.cog_name if cmd.cog else 'None'})")
async def main():
db.init_db()
await load_cogs()
await b.start(os.getenv("DISCORD_TOKEN"))
if __name__ == "__main__":
asyncio.run(main())
https://gist.github.com/JuanGomezBot/6d ... a24484f6f1 (код слишком длинный, чтобы его можно было показать здесь)
Я пытался использоватьchatgpt, но у них ужасная память, и deepseek думает очень долгое время не приводило к решению
Подробнее здесь: https://stackoverflow.com/questions/798 ... ands-twice
Мобильная версия