i already have 3 perfectly running app_commands, which also get shown when you type in "/" in the discord chat. But when i try to make a 4th one, even a simple one just for testing, now mather how much i sync it doesnt come up in the commands list. And yes, i not only searched in "recently used commands" like an idiot.
Here is my 4th command(which doesnt show up):
its a simple message, nothing fancy.
@app_commands.command(name="tell_me_a_joke",description="tells you a *joke* ;)")
async def joke(self,ctx:discord.Interaction):
await ctx.response.send_message("https://u.gg/lol/profile/euw1/thebausffs-euw/overview")
This is one of the 3 working commands:
@app_commands.command(name="roll_a_dice", description="like the name states, this command roles a dice.")
async def dice(self,ctx: discord.Interaction):
zahl = rs.randint(1,6)
messagelist = [f"The dice shows **{str(zahl)}** eyes.",f"A **{str(zahl)}** was rolled", f"You threw a **{str(zahl)}**"]
await ctx.response.send_message(rs.choice(messagelist))
I even tried kicking the bot from the server and reinviting him, because that solved some problems in the past. I local synced on the guilde and globally. What is the problem? Do i just need to wait longer cuz the discord servers are slow?
App commands have a 200 command creates per day limit. Source Because app commands are global discord wants you to create them once. As Silvio said here: Silvios Answer
That's create commands. You only need to create each command once, not once per bot run. Discord associates the commands with your bot's unique ID.
He also mentions how to solve it I recommend reading the original answer.
However using app commands is not usually recommended for simple bots and simple actions. Using bot.commands has no limit and it's really beginner friendly. Here's a code snippet how it would work with bot.command:
import discord
from discord.ext import commands
intents = discord.Intents.all() #Can be changed for more specific intents.
bot = commands.Bot(intents=intents,command_prefix="!!") #You can use any prefix other than slash.
#Slash commands are created differently.
@bot.event
async def on_ready(): #It's good practice to have on_ready function
print(f"Logged in as {bot.user.name}") #Successfully loaded the bot
@bot.command(help="Tells you a *joke* ;)") #when [yourprefix]help [thiscommandsname] used it will show this description
async def joke(ctx):
await ctx.send("https://u.gg/lol/profile/euw1/thebausffs-euw/overview")
bot.run("YourBotToken")
The downside of this method is you can't get feedback while typing the command like you do in app_commands. But you can still use the help command with your prefix.