so i have a discord bot which is split up into multiple python files that i imported and when i import them into main.py it always only syncs the commands from the last import and disregards all of the rest. these are the imports. (i do have all of the required imports)
@client.event
async def on_ready():
print("bot is ready, you can now leave the tab")
embed = discord.Embed(colour=discord.Colour.blue())
channel = client.get_channel(channel id here)
embed.add_field(name=f'back online',
value='bot has been updated',
inline=False)
await channel.send(embed=embed)
try:
synced = await client.tree.sync()
print(f"synced {len(synced)} commands")
except Exception as e:
print(e)
from cogs.admin import *
from cogs.data import *
from cogs.economy import *
from cogs.fun import *
from cogs.gambling import *
from cogs.help import *
from cogs.inventory import *
from cogs.leveling import *
from cogs.market import *
from cogs.polls import *
from cogs.role_colors import *
from cogs.shop import *
from cogs.warnings import *
from cogs.xp_boosters import *
and here is the example code for one of the cogs--------------------------------------------
intents = discord.Intents.default()
intents.members = True
client = commands.Bot(command_prefix='.', intents=discord.Intents.all())
client.remove_command('help')
@client.event
async def on_ready():
print("BOT is ready, you can now leave the tab")
try:
synced = await client.tree.sync()
print(f"synced {len(synced)} commands")
except Exception as e:
print(e)
@client.tree.command(name="say", description = "what to say.")
@app_commands.describe(say= "text")
async def _8ball(interaction: discord.Interaction, say: str):
if not interaction.user.guild_permissions.administrator:`enter code here`
return await interaction.response.send_message("You are not an admin.")
await interaction.response.send_message(f'{say}')
This problem is related to ambiguities. You probably gave the same class name to all your Cogs and when you use import *
, you are overwriting the previous import. Using import *
is a bad practice. I recommend just using import cogs
and throughout your code refer to it using cogs.fun.xxx
.