I've been making a bot for fun (and to learn) and noticed my command aren't previewed like you would see for other bots. Here is an example of a bot I made using javascript:
As you can see, when typing a '/' into the the message bar, the user gets a preview of all commands that use '/'. However, my bot's commands are not added to this list but still work.
How do I register these commands in a way that shows users the available commands when they type the command prefix? I will attach my source code to the bottom of this post. Thank you for the help!
import discord
import os
from discord.ext import commands
from dotenv import load_dotenv
from datetime import datetime, timezone
load_dotenv()
__TOKEN = os.getenv('DISCORD_TOKEN')
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix='/', intents=intents)
active_channel = 'testing'
@bot.event
async def on_ready():
try:
print(f'Signed in as { bot.user }')
await bot.tree.sync()
print(f"Successfully synced commands.")
except Exception as e:
print(e)
@bot.event
async def on_message(message):
if (message.author == bot.user):
return
if (message.channel == active_channel):
if ('uncle terry' in message.content):
await message.channel.send('Hi')
await bot.process_commands(message)
@bot.command(name='ping')
async def ping(ctx):
await ctx.send('pong')
@bot.command(name='time')
async def time(ctx):
await ctx.send(f"It is {datetime.now(timezone.utc)} UTC.")
bot.run(__TOKEN)
Note: The bot is a little goofy and meant to be in my friends' server, so don't make fun of it too much :)