0

Добавил в бота дискорд слэш команды, но перестали работать текстовые. Не понимаю с чем это связанно и как решить эту проблему.

import disnake
from disnake.ext import commands 

client = commands.Bot(command_prefix=commands.when_mentioned, sync_commands_debug=True, test_guilds= [968372517326708786])

@client.event
async def on_ready():
    print('We have logged in as {0.user}'.format(client))

@client.slash_command(description="Команды")
async def cmds(inter):
    await inter.response.send_message("Команды:\nКу\nПривет\nДаров\nХай\nСалам\nШалом\nhelp\ninfo")
    
@client.event
async def on_message(message):
    if message.author == client.user:  
        return
    prefix = "&"
    if message.content.startswith(prefix + 'Привет'):         #Привет
        await message.channel.send('Hello!')
    if message.content.startswith(prefix + 'привет'):
        await message.channel.send('Hello!')
#    if message.content.startswith(prefix + 'Прив'):           #Прив
#        await message.channel.send('Hello!')
#    if message.content.startswith(prefix + 'прив'):
#        await message.channel.send('Hello!')
#    if message.content.startswith(prefix + "Всем привет"):    #Всем привет
#        await message.channel.send('Привет!')
#    if message.content.startswith(prefix + "всем привет"):
#        await message.channel.send('Привет!')
    if message.content.startswith(prefix + "Ку"):             #Ку
        await message.channel.send('Даров!')
    if message.content.startswith(prefix + "ку"):
        await message.channel.send('Даров!')
    if message.content.startswith(prefix + "Хай"):            #Хай
        await message.channel.send('Приветик!')
    if message.content.startswith(prefix + "хай"):
        await message.channel.send('Приветик!')
    if message.content.startswith(prefix + "Даров"):          #Даров
        await message.channel.send('Хай!')
    if message.content.startswith(prefix + "даров"):
        await message.channel.send('Хай!')
    if message.content.startswith(prefix + "Салам"):          #Салам
        await message.channel.send('Салют!')
    if message.content.startswith(prefix + "салам"):
        await message.channel.send('Салют!')
    if message.content.startswith(prefix + "Шалом"):           #Шалом
        await message.channel.send('Здрасьте!')
    if message.content.startswith(prefix + "шалом"):
        await message.channel.send('Здрасьте!')
    if message.content.startswith(prefix + "help"):
        emb = discord.Embed(title="Нужна помощь? Я откликаюсь на:", description="\n&Привет\n&Всем привет\n&Ку\n&Хай\n&Даров\n&Салам\n&Прив\n&Шалом")
        await message.channel.send(embed=emb)
    if message.content.startswith(prefix + "info"):
        emb = discord.Embed(title="Обо мне", description="\nПросто бот. Создан **@Bad Boy#4708** 05.05.2022. В даный момент нахдится на бета тесте на сервере AlexGyver community\n\nВерсия 1.0 beta")
        await message.channel.send(embed=emb)
            

client.run(TOKEN)
1

1 ответ 1

0

Чтобы создавать команды не нужно делать проверки с startswith в on_message

client = commands.Bot(command_prefix=!, intents=discord.Intents.all())

Сделали префикс !(для примера). А дальше создаёте асинхронные функции, например:

@client.command(aliases=['удалить'])
async def delete(ctx, amount: int=None)
    await ctx.channel.purge(limit=amount)
    await ctx.send(f'Удалено {amount} сообщений!')

Тогда не будет проблем с слеш и текстовыми командами.

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.