From ecddf0b36b4c78ace3717f47dfb1b683d6872f33 Mon Sep 17 00:00:00 2001 From: Xarlos <57622136+Xarlos89@users.noreply.github.com> Date: Tue, 14 May 2024 18:46:00 +0200 Subject: [PATCH 1/2] Issue with the name of the class conflicting with the command. --- src/cogs/general_cogs/healthcheck.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cogs/general_cogs/healthcheck.py b/src/cogs/general_cogs/healthcheck.py index 25dd233..11299f7 100644 --- a/src/cogs/general_cogs/healthcheck.py +++ b/src/cogs/general_cogs/healthcheck.py @@ -3,11 +3,12 @@ from discord.ext import commands + # We add our logger to the cog. logger = logging.getLogger(__name__) -class Ping(commands.Cog): +class Healthcheck(discord.ext.commands.Cog): """ All cogs are added into their own class. If an error occurs in the cog, the cog itself will fail and restart. @@ -28,4 +29,4 @@ async def ping(self, interaction: discord.Interaction): async def setup(bot: commands.Bot) -> None: """ Cogs setup functions are mandatory for cog initialization""" - await bot.add_cog(Ping(bot)) + await bot.add_cog(Healthcheck(bot)) From d46245cf7c331abce913d82fb6f3e98de732926a Mon Sep 17 00:00:00 2001 From: Xarlos <57622136+Xarlos89@users.noreply.github.com> Date: Tue, 14 May 2024 20:44:42 +0200 Subject: [PATCH 2/2] Updated ping to a prefix command. Just use ">ping" --- src/cogs/general_cogs/healthcheck.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/cogs/general_cogs/healthcheck.py b/src/cogs/general_cogs/healthcheck.py index 11299f7..2fc4fbb 100644 --- a/src/cogs/general_cogs/healthcheck.py +++ b/src/cogs/general_cogs/healthcheck.py @@ -2,8 +2,6 @@ import discord from discord.ext import commands - - # We add our logger to the cog. logger = logging.getLogger(__name__) @@ -14,17 +12,18 @@ class Healthcheck(discord.ext.commands.Cog): If an error occurs in the cog, the cog itself will fail and restart. It will NOT bring down the bot with it. """ + def __init__(self, bot: commands.Bot) -> None: """ Initialize the class using the bot object from __main__ """ self.bot = bot - @discord.app_commands.command(name="ping") - async def ping(self, interaction: discord.Interaction): - logger.info(f"ping command used by {interaction.user.name}") + @commands.command(name="ping") + async def ping(self, ctx): + logger.info(f"ping command used by {ctx.author.name}") shit_speed = f"{str(round(self.bot.latency * 1000))} ms" - embed = discord.Embed(title="**Pong!**", description="**" + shit_speed + "**", color=0xafdafc) - await interaction.response.send_message(embed=embed) + embed = discord.Embed(title="**Pong!**", description=f"**{shit_speed}**", color=0xafdafc) + await ctx.reply(embed=embed) async def setup(bot: commands.Bot) -> None: