Это мой файл main.py:
Код: Выделить всё
import discord
from discord import app_commands
from discord.ext import commands, tasks
import datetime
import os
bot = commands.Bot(
command_prefix=",",
intents=discord.Intents.all(),
status=discord.Status.dnd,
activity=discord.Activity(
type=discord.ActivityType.watching, name="Ursf"
),
)
bot.remove_command("help")
@bot.event
async def on_ready():
try:
await bot.tree.sync()
guild = discord.Object(id={guild_id_here})
await bot.tree.sync(guild=guild)
print(f"Slash commands synced to guild: {guild.id}")
except Exception as e:
print(f"Failed to sync commands: {e}")
print("\n\n bot is ready!")
for fn in os.listdir("./cogs"):
if fn.endswith(".py"):
try:
await bot.load_extension(f"cogs.{fn[:-3]}")
print(f"\n loaded extensions: {fn}")
except Exception as e:
print(f" failed to load extension(s) {fn}: {e}")
bot.run("{token}")
Код: Выделить всё
class SipBot(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.hybrid_command(name="hello", description="Says hello")
async def newhello(self, ctx):
await ctx.send("Hello from both prefix and slash")
async def setup(bot):
await bot.add_cog(SipBot(bot))
Для получения дополнительной информации я использую VS2022 и Python версии 3.11. версия discord.py — 2.4.0, и у меня не установлен пакет discord (на случай конфликта).
Есть предложения? Команда, которую я пытаюсь создать, имеет множество аргументов, поэтому мне нужно визуально показать аргументы (как это может сделать команда с косой чертой) или просто запустить модальное окно из указанной команды с косой чертой.
Подробнее здесь: https://stackoverflow.com/questions/790 ... ot-working