Hello, so i started a discord bot project for fun but i have one issue, the new slash command that i add wont show in discord, in terminal it says "Synced 3 commands" but when i type "/" in discord i only see the "remove" command but when i go to settings --> integrations --> manager bot i see all 3 commands over there
import discord
from discord.ext import commands
import os
import json
import time
import asyncio
intents = discord.Intents.all()
client = commands.Bot(command_prefix='!', intents=intents)
with open("config.json", "r+", encoding="utf-8") as f:
config = json.load(f)
token = config["token"]
@client.event
async def on_ready():
print(f"[!] {time.strftime('%Y-%m-%d - %H:%M')}: bot is online")
print(f"[!] Logged in as: {client.user} - {client.user.id}")
@client.event
async def on_guild_join(guild: discord.Guild):
await client.tree.sync(guild=guild)
@client.event
async def setup_hook():
logs = await client.tree.sync()
print(f"[!] Synced {len(logs)} commands")
async def loadcogs():
for filename in os.listdir('./Commands'):
if filename.endswith('.py'):
await client.load_extension(f'Commands.{filename[:-3]}')
async def startup():
async with client:
await loadcogs()
await client.start(token)
asyncio.run(startup())
from discord.ext import commands
from discord import app_commands
import discord
class Economy(commands.Cog):
def __init__(self, client):
self.client = client
@app_commands.command(name="addmoney", description="Command to add money")
async def add_money(self, interaction: discord.Interaction):
await interaction.response.send_message("test command...")
return
@app_commands.command(name="remove", description="Command to remove money")
async def remove_money(self, interaction: discord.Interaction):
await interaction.response.send_message("test command...")
return
@app_commands.command(name="balance", description="Command to check balance")
async def balance(self, interaction: discord.Interaction):
await interaction.response.send_message("test command...")
return
async def setup(client):
await client.add_cog(Economy(client))