Antsently
@Antsently

Почему так происходит с префиксом?

Я использую такой код:
import disnake 
#all necessary imports

load_dotenv(find_dotenv(filename='settings/.env'))

intents = disnake.Intents.all()

async def get_prefix(client, message):
    config_path = 'settings/config.json'
    with open(config_path, 'r') as config_file:
        config_data = json.load(config_file)
    pref_fin = config_data.get('PREFIX', '!')
    return commands.when_mentioned_or(pref_fin)(client, message)


bot = commands.Bot(command_prefix=get_prefix,
                   intents=intents, help_command=None)

TOKEN = os.getenv('TOKEN')

# I use cog for modules.
directories = [
    os.path.abspath("./res"),
    os.path.abspath("./res/Service"),
    os.path.abspath("./res/Command"),
    os.path.abspath("./res/Slash")
]

loaded_extensions = []

for directory in directories:
    for root, _, files in os.walk(directory):
        for file in files:
            if file.endswith(".py"):
                package = root.replace(os.path.abspath(
                    "."), "").replace(os.path.sep, ".")[1:]
                extension = f"{package}.{file[:-3]}"
                if extension not in loaded_extensions:
                    loaded_extensions.append(extension)
                    bot.load_extension(extension)

bot.run(TOKEN)


В консоле такой вывод:
MessageContentPrefixWarning: Message Content intent is not enabled and a prefix is configured. This may cause limited functionality for prefix commands. If you want prefix commands, pass an intents object with message_content set to True. If you don't need any prefix functionality, consider using InteractionBot. Alternatively, set prefix to disnake.ext.commands.when_mentioned to silence this warning.
  bot = commands.Bot(command_prefix="!")
  • Вопрос задан
  • 105 просмотров
Решения вопроса 1
bitler
@bitler
Попробуй насильно поставить интент, посмотреть в исходниках как определён ALL. Это вопрос к разработчикам библиотеки. https://github.com/DisnakeDev/disnake/issues.
https://github.com/DisnakeDev/disnake/blob/a5c1a8f...
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы