python 3.x – discord not registering commands anymore

I have read all the help files online.. i’ve done TONS of research and still nothing helps me.. i HAD a command that ran whats inside “on_raw_reaction_add”, basically same code. I edited the command to be “better” and had some more functionallity and now the entire bot won’t take ANY command. heres my code for the bot

from discord.ext.commands import Bot
import discord
from discord.ext import tasks
intents = discord.Intents().all()
intents.reactions = True
intents.members = True
import os.path
import requests
import asyncio
import random
from google.cloud import vision

os.environ["GOOGLE_APPLICATION_CREDENTIALS"]="/var/bots/rev/rev-cogs/keyFile.json"

bot = Bot(command_prefix="p-", intents=intents)
token = 'TOKEN'
bot.remove_command("help")



@bot.event
async def on_raw_reaction_add(payload):
    channel = bot.get_channel(payload.channel_id)
    if isinstance(channel, discord.DMChannel):
        return
    message = await channel.fetch_message(payload.message_id)
    guild = bot.get_guild(payload.guild_id)
    user = guild.get_member(payload.user_id)
    emoji = payload.emoji.name
    reaction = discord.utils.get(message.reactions, emoji=emoji)
    member = payload.member
    if emoji == '🔍':
        msg = await channel.fetch_message(payload.message_id)
        if msg.attachments:
            uri = msg.attachments[0].url
        else:
            embed=discord.Embed(title="Warning: Error Detected!")
            embed.add_field(name="Error", value="Index out of Range", inline=False)
            embed.add_field(name="What does this mean?", value="Sometimes the way the bot is programmed just simply doesn't get the URL from the reaction :mag: to get around this manually scan the URL with `-search [url]` in a DM with the bot!", inline=False)
            embed.set_footer(text="Sent by ReversernCome order bots from killaxia: https://bots.killaxia.com")
            await member.send(embed=embed)

        fmatches = []
        lfull = 0
        lpar = 0
        images = []
        visually = []
        lvisual = 0
        web = []
        result = []
        partials = []
        client = vision.ImageAnnotatorClient()
        image = vision.Image()
        image.source.image_uri = uri

        response = client.web_detection(image=image)
        print(response)
        annotations = response.web_detection
        if annotations.best_guess_labels:
            for label in annotations.best_guess_labels:
                print('nBest guess label: {}'.format(label.label))
            thelabel = label.label

        for url in annotations.full_matching_images:
            fmatches.append(f"{url}<br><br>")
        lfull = len(fmatches)

        for url in annotations.partial_matching_images:
            partials.append(f"{url}<br><br>")
        lfull = len(partials)

        for url in annotations.visually_similar_images:
            visually.append(f"{url}<br><br>")
        lvisual = len(visually)

        if annotations.web_entities:
            web = len(annotations.web_entities)

            for entity in annotations.web_entities:
                result.append(f"{entity.score} - {entity.description}<br>")

        foldername = random.randint(1, 50000000)
        endname = random.randint(5000,5000000)
        directory = f"{foldername}_{endname}"
        parent_dir = "/var/www/html/searches"
        path = os.path.join(parent_dir, directory)
        os.mkdir(path)
        print("Directory '% s' created" % directory)
        f = open(f"/var/www/html/searches/{foldername}_{endname}/all_info.txt", 'w+')
        f.write(str(response))
        f.close()
        all_info = f"https://bots.killaxia.com/searches/{foldername}_{endname}/all_info.txt"
        f = open(f"/var/www/html/searches/{foldername}_{endname}/partial_links.txt", 'w+')
        f.write("Partial Matching URLs:nn")
        f.write(str(partials))
        f.close()
        partial_info = f"https://bots.killaxia.com/searches/{foldername}_{endname}/partial_links.txt"
        f = open(f"/var/www/html/searches/{foldername}_{endname}/full_links.txt", 'w+')
        f.write("Full Matching URLs:nn")
        f.write(str(fmatches))
        f.close()
        full_info = f"https://bots.killaxia.com/searches/{foldername}_{endname}/full_links.txt"
        f = open(f"/var/www/html/searches/{foldername}_{endname}/similar_links.txt", 'w+')
        f.write("Visually Similar Images:nn")
        f.write(str(visually))
        f.close()
        visual_info = f"https://bots.killaxia.com/searches/{foldername}_{endname}/similar_links.txt"

        if len(str(lfull)) < 0:
            lfull = 0
        if len(str(lpar)) < 0:
            lpar = 0
        if len(str(lvisual)) < 0:
            lvisual = 0
        score = int(lfull) + int(lpar) + int(lvisual)
        if score >= 12:
            catfish = True
        else: 
            catfish = False

        embed=discord.Embed(title="Reverse Image Search Results", description="Did you spot a catfish?")
        embed.set_thumbnail(url=uri)
        embed.add_field(name="Full Matches", value=f"{lfull}", inline=False)
        embed.add_field(name="Partial Matches", value=f"{lpar}", inline=False)
        embed.add_field(name="Visually Similar Matches", value=f"{lvisual}", inline=False)
        embed.add_field(name="Score and thoughts", value=f"Score: {score}nCatfish status: {catfish}n", inline=False)
        embed.add_field(name="Additional Information", value=f"Entire history of image:n{all_info}nnFull Matching Links on this images:n{full_info}nnPartial Mathing Links on this image:n{partial_info}nnVisually Similar Matching Links on this image:n{visual_info}n", inline=False)
        embed.add_field(name="Web Entities", value=f"{web}", inline=False)
        embed.add_field(name="Web Score/Description", value=f"{result}", inline=False)
        embed.add_field(name="Best Guess", value=f"{thelabel}", inline=False)
        embed.add_field(name="Add the bot", value=f"https://top.gg/bot/995629684333228102", inline=False)
        embed.set_footer(text=f"Wanna support the developer and keep this project online?nCashapp: $allusivegold - Paypal: https://paypal.me/killaxia")
        await member.send(embed=embed)

                
for filename in os.listdir('/var/bots/rev/rev-cogs'):
    if filename.endswith('.py'):
        bot.load_extension(f'rev-cogs.{filename[:-3]}')
        print(f"{filename} loaded!")


@bot.event
async def on_ready():
    print('Member count updated')
    print("Bot in server: {}".format("Success"))
    print("Bot name: {}".format(bot.user.name))
    ip = requests.get('https://ipinfo.io/ip').text
    print(ip)
    members = 0
    for guild in bot.guilds:
        members += guild.member_count - 1
    await bot.change_presence(activity=discord.Activity(
        type=discord.ActivityType.watching, name=f'.help with {members} members'))



  

#run token
bot.run(token)

This part works just fine! It says the cog is loaded, too.. heres the cog..

from discord.ext.commands import Bot
import discord
from discord.ext import tasks
intents = discord.Intents().all()
intents.reactions = True
intents.members = True
from datetime import date
from google.cloud import vision

os.environ["GOOGLE_APPLICATION_CREDENTIALS"]="/var/bots/rev/rev-cogs/keyFile.json"

self.bot.remove_command("help")


class Imager(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.command
    async def test(self, ctx):
        print("test")


def setup(bot):
  bot.add_cog(Imager(bot))

This code worked JUST FINE before something happened.. now all i get, for evertything is this: Ignoring exception in command None: discord.ext.commands.errors.CommandNotFound: Command “test” is not found

Even if i replace all the file names, command names, clear ubuntu cache, restart server, reload server to an earlier date (snapshot).. remove commands, etc etc.. this is just broken. I have tried literally everything..please..please help me 🙁

Leave a Comment