@CaTcRuSh

Почему команды в discord.py не работают?

Я сидел, добавлял новые команды в бота, и ВСЕ команды перестали работать. Работает только одна.

Мой код:

import discord
from discord.ext import commands
import os, sqlite3
import string, json
import requests
import youtube_dl
import asyncio
import functools
import itertools
import math
import random
#import pymongo
from async_timeout import timeout
from pymongo import MongoClient

bot = commands.Bot(command_prefix='?')

@bot.event
async def on_ready():
	print('Питон приполз на сервер')


	global base, cur
	base = sqlite3.connect('Питон.db')
	cur = base.cursor()
	if base:
		print('Database connected...OK')


@bot.command()
async def статус(ctx):
	await ctx.send('Питон сидит здесь.')

@bot.command()
async def сказать(ctx, *, arg):
	await ctx.send(arg)

@bot.command()
async def инфо(ctx):
	await ctx.send('Я - Питон . Слежу за порядком в чате.')

@bot.event
async def on_message(message):
	if 'как дела' in message.content.lower():
		await message.channel.send('Норм.')

@bot.event
async def on_message(message):
	if 'привет' in message.content.lower():
		await message.channel.send('Ку!')

@bot.event
async def on_message(message):
   if 'https://' in message.content:
      await message.delete()
      await message.channel.send(f"{message.author.mention}, не рассылайте ссылки!")
   else:
      await bot.process_commands(message)

@bot.command()
async def кот(ctx):
    response = requests.get('https://some-random-api.ml/img/cat') # Get-запрос
    json_data = json.loads(response.text) # Извлекаем JSON
    embed = discord.Embed(color = 0xff9900, title = 'Случайный кот.') # Создание Embed'a
    embed.set_image(url = json_data['link']) # Устанавливаем картинку Embed'a
    await ctx.send(embed = embed) # Отправляем Embed

@bot.command()
async def пёс(ctx):
    response = requests.get('https://some-random-api.ml/img/dog') # Get-запрос
    json_data = json.loads(response.text) # Извлекаем JSON

    embed = discord.Embed(color = 0xff9900, title = 'Случайная собака.') # Создание Embed'a
    embed.set_image(url = json_data['link']) # Устанавливаем картинку Embed'a
    await ctx.send(embed = embed) # Отправляем Embed

@bot.command()
async def лис(ctx):
    response = requests.get('https://some-random-api.ml/img/fox') # Get-запрос
    json_data = json.loads(response.text) # Извлекаем JSON

    embed = discord.Embed(color = 0xff9900, title = 'Случайный лис.') # Создание Embed'a
    embed.set_image(url = json_data['link']) # Устанавливаем картинку Embed'a
    await ctx.send(embed = embed) # Отправляем Embed

@bot.command()
async def мем(ctx):
    response = requests.get('https://some-random-api.ml/meme')
    json_data = response.json()
    embed = discord.Embed(title = 'Вот мемчик:')
    embed.set_image(url = json_data ['image'])
    await ctx.send(embed = embed)

@bot.command() 
async def сколько(ctx, *nums):
    operation = " + ".join(nums)
    await ctx.send(f'{operation} = {eval(operation)}')

@bot.event
async def on_message(message):
    if message.content.startswith("?угадайка"): #command to start quessing game
        channel = message.channel
        await channel.send("Угадайте число от 0 до 10, написав число в этом канале!") #message that tells about the start of the game

        number1 = random.randint(1,10) #picking random number from 1 - 10 and printing it
        print(number1)
        
        number2 = str(number1) #converting int to str

        def check(m):
            return m.content == number2 and m.channel == channel #checking answers
        
        msg = await bot.wait_for('message', check=check)
        await channel.send("Отгадал: {.author}" .format(msg)) #tells who got the answer



bot.run(os.getenv('TOKEN'))
  • Вопрос задан
  • 1269 просмотров
Пригласить эксперта
Ответы на вопрос 1
@NoGrisha
Точка.
Ваш код когда видит что было высланно сообщение, проверяет его и игнорирует проверку команды. Добавьте в on_message следующую строчку кода:
await process_commands(message)
Ответ написан
Комментировать
Ваш ответ на вопрос

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

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