Traceback (most recent call last):
File "/home/runner/Porto-SeguroBOT-LAUDOS/main.py", line 3, in <module>
from discord_slash import SlashCommand
ModuleNotFoundError: No module named 'discord_slash'
Repl link:
import discord
from discord.ext import commands
from discord_slash import SlashCommand
# Defina as intenções que o bot usará
ntents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix="/", intents=intents)
slash = SlashCommand(bot, sync_commands=True)
# Crie uma instância do bot com as intenções
bot = discord.Client(intents=intents)
# Inicialize o SlashCommand com a instância do bot
slash = SlashCommand(bot, sync_commands=True)
# Evento que é disparado quando o bot está online
@bot.event
async def on_ready():
print(f"Bot está online como {bot.user.name}")
user_id = 539148230840025098 # Substitua pelo ID do usuário desejado
user = await bot.fetch_user(user_id)
if user:
message = "Olá Moonnel, eu acabei de ligar ok"
await user.send(message)
# Comando 'Teste' transformado em slash command
@slash.slash(name="teste", description="Mostra o status atual do bot")
async def teste(ctx):
status = bot.user.status
await ctx.send(f"O status atual do bot é: {status}")
# Rodar o bot
bot.run("TOKEN")
in future, please link the repl. You can do that without exposing your token (which I easily found anyhow) – check your Discord DMs…
In the “Packages” tool, add discord-py-interactions and replace discord_slash in your code with interactions.
from interactions import SlashCommand
ImportError: cannot import name 'SlashCommand' from 'interactions' (/home/runner/Porto-SeguroBOT-LAUDOS/.pythonlibs/lib/python3.10/site-packages/interactions/__init__.py)
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f56b3696680>
I would still use the built-in tree commands within discord.py; it’s just much easier. Plus, as you said, they’re actively maintained. But honestly, nextcord is even better as it is more actively maintained and not deprecated within voice activities.