#🔒 Python Discord

19 messages · Page 1 of 1 (latest)

lost vessel
#

I am having a problem with old commands I ran in the python script are staying persistant in the discord server as "available" commands. Is this just an issue of it takes time? This is the code I run

Discord Imports

import discord
from discord.ext import commands

Other Imports

import requests
import time
import json
import os
from dotenv import load_dotenv

load_dotenv()

intents = discord.Intents.all()
bot = commands.Bot(command_prefix='/', intents=intents)

@bot.hybrid_command()
async def ping(ctx: commands.Context):
await ctx.send('pong')

@bot.hybrid_command()
async def yourmom(ctx: commands.Context):
await ctx.send('is cool')

@bot.event
async def on_ready():
print(f'{bot.user} has connected to Discord!')
print('---------')
await bot.tree.sync()

bot.run(os.getenv('DISCORD_TOKEN'))

(other imports not seen here are for twitch integration)

abstract gyroBOT
#

@lost vessel

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

lost vessel
#

[2024-04-01 04:51:03] [ERROR ] discord.app_commands.tree: Ignoring exception in command tree
Traceback (most recent call last):
File "C:\Users\dmaug\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\app_commands\tree.py", line 1089, in wrapper
await self._call(interaction)
File "C:\Users\dmaug\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\app_commands\tree.py", line 1221, in _call
command, options = self._get_app_command_options(data)
File "C:\Users\dmaug\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\app_commands\tree.py", line 1125, in _get_app_command_options
raise CommandNotFound(name, parents)
discord.app_commands.errors.CommandNotFound: Application command 'add' not found

error code due to that command not existing anymore in the code

empty hinge
lost vessel
#

I believe I’m using discord.py, not a thousand percent tho

#

My current on ready function doesn’t already sync?

empty hinge
#

Yeah.
You could also kick your bot and re-add it, that should remove the lingering commands

empty hinge
#

I've had it happen where commands I add work in some servers, but don't work without those lines.

lost vessel
#

Aye I’ll try that later when I wake up I’ve been messing around with all that for 5 hours now

empty hinge
#

One of the fun things of making a discord bot hah

lost vessel
#

happened upon this YouTube video EXTREMELY simplifying the same process

empty hinge
#

Youtube is one of your best friends when it comes to discord bots

lost vessel
#

Pretty much straight from the docs

lost vessel
empty hinge
#

Np, hope it helps

abstract gyroBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.