import nextcord
from nextcord.ext import commands
import apikeys
import aiohttp
import os
intents = nextcord.Intents.default()
intents.message_content = True
intents.members = True
bot = commands.Bot(command_prefix='!', intents=intents)
@bot.event
async def on_ready():
await bot.sync_all_application_commands()
await bot.change_presence(status=nextcord.Status.do_not_disturb)
print(f"Logged in as {bot.user}")
print("The bot is now ready for use!")
print("-----------------------------")
@bot.slash_command(name="shutdown", description="Shuts down the bot.")
async def shutdown(interaction: nextcord.Interaction):
await interaction.send("Shutting down bot...")
await bot.close()
await aiohttp.ClientSession().close()
initial_extension = []
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
initial_extension.append("cogs."+ filename[:-3])
if __name__ == "__main__":
for extension in initial_extension:
bot.load_extension(extension)
bot.run(apikeys.bot_token)```
#Some slash commands show up on my alt, but some dont.
1 messages · Page 1 of 1 (latest)
That is my main.py
This is my other.py, a cog with some random commands:
https://paste.nextcord.dev/?id=1739983657378473
For some reason, role_remove shows up, but role_add does not show up, even tho they are the exact same code!
looks like your indentation is wrong
It didnt work
purge also had wrong identation but that one does show up
i dont even understand how could your code run if there was wrong indentation..
are u even saving your files?
Did you find something else in my code?
Could just be weird copy paste
1 thing tho when i have administrator perms all commands show up
or i prob accedentally pressed tab instead of alt tab
- dont put
await bot.sync_all_application_commands()in on_ready. again, nextcord syncs commands automatically on startup.
1.1. because you did put in there, and if you restarted bot couple of times, you could hit ratelimit, as external usage of that function is not recommended.
rn just remove await bot.sync_all_application_commands() from on_ready, wait 5-10 minutes, restart your bot and refresh your discord client
should show up
@charred creek its fixed
it turned out that i had overrides enabled inside my server integration settings
alr. but don't ignore what i said above
i turned all overrides off and now they show up
Okay
even better solution is to pass guild_ids inside of your commands while you are developing them
and then when you are ready to deploy your bot to production, remove guild_ids from command
Wait what would that do?
as long as the amount a block is indented is consistent, the exact amount of indentation is actually irrelevant
def ok():
x = 1
return x
def also_ok():
x = 1
return x
def not_ok():
x = 1
return x