It happens on the FIRST command I create, it's just a "ping" command that shows the latency of the bot.
That command is not shown on Discord but on VS Code, there's no errors raised.
main :
import disnake, os
from disnake.ext import commands
from config import token
import sys; sys.dont_write_bytecode = True
class Bot(commands.AutoShardedInteractionBot):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
async def on_connect(self) -> None:
print(f"Logged in as {self.user}")
async def on_ready(self) -> None:
await self.change_presence(activity=disnake.Activity(name="Disnake", type=disnake.ActivityType.watching), status=disnake.Status.do_not_disturb)
if __name__ == '__main__':
bot = Bot(intents = disnake.Intents.default(), test_guilds = [])
for file in os.listdir('./cogs/'):
if not file.endswith('.py'):
continue
bot.load_extension(f"cogs.{file[:-3]}")
print(f"cogs.{file[:-3]} has been loaded")
bot.run(token)
ping command :
import disnake
from disnake.ext import commands
class Ping(commands.Cog):
def __init__(self, bot: commands.AutoShardedInteractionBot) -> None:
self.bot = bot
@commands.Cog.listener()
async def on_ready(self) -> None:
print("Sent from ping.py")
@commands.slash_command(name="ping", description="tells bot's latency")
async def ping(self, inter: disnake.CommandInteraction) -> None:
await inter.send(f"You just got pong'd !\nMy latency is **{int(self.bot.latency * 1000)}ms**.")
def setup(self: commands.AutoShardedBot) -> None:
self.add_cog(Ping(self))
