im trying to add cogs to my very long python discord bot, but when i added the cog it says 0 commands synced and i cant do the slash command in my server. i am trying to implement a command that has basically everything i need as a test and i load the command. it recognises and loads the cog but it doesnt seem the load the command, im assuming the problem is in the cog and not in main.py.
main.py
imports
activities = [
discord.Game(name="help"),
discord.Game(name="me")
]
intents = discord.Intents.all()
intents.members = True
client = commands.Bot(command_prefix='.', intents=discord.Intents.all())
client.remove_command('help')
rcolor = [
discord.Colour.blurple()
]
@client.event
async def on_ready():
for file in os.listdir("cogs"):
if file.endswith(".py"):
await client.load_extension(f"cogs.{file[:-3]}")
print("NOAAHBOT is ready, you can now leave the tab")
embed = discord.Embed(colour=discord.Colour.blurple())
channel = client.get_channel(channelidhere)
embed.add_field(name=f'back online',
value='noaahbot 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)
while True:
for activity in activities:
await client.change_presence(activity=activity)
await asyncio.sleep(2)
client.run("Token")
cog
import discord
from discord import app_commands
from discord.ext import commands
class SayCog(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command(name="say", description="What should the bot say")
@app_commands.describe(thing_to_say = "text")
async def say(interaction: discord.Interaction, thing_to_say: str | None):
if not interaction.user.guild_permissions.administrator:
return await interaction.response.send_message("You require administator permisions to use this command")
if thing_to_say is None:
await interaction.response.send_message(f'nothing to be said')
else:
await interaction.response.send_message(f'{thing_to_say}')
async def setup(client):
await client.add_cog(SayCog(client))`
You're loading a normal command, not a slash command. To load a slash command inside a cog you have to do:
@app_commands.command() instead of @commands.command