Почему у меня бот не реагирует на команды? Discord.py
Бот не реагирует на команды, хотя сам бот запускается, помогите!
import kick
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
intents = discord.Intents.all()
intents.message_content = True
bot = commands.Bot(command_prefix='!', intents=intents)
TOKEN = ''
@bot.event
async def on_message(message):
# do some extra stuff here
await bot.process_commands(message)
@bot.listen('on_message')
async def whatever_you_want_to_call_it(message):
# do stuff here
# do not process commands here
@bot.event
async def on_ready():
print(f'{bot.user} запущен и готов к работе!')
@bot.command()
async def pg(ctx):
await ctx.send('Я в работе!')
@bot.command()
async def helps(ctx):
await ctx.send('pg - проверка работаспособности бота. kick - выгнать пользователя с discord ')
global base, cur
base = sqlite3.connect('Питон.db')
cur = base.cursor()
if base:
print('Database connected...OK')
@bot.command()
async def Ping(ctx):
await ctx.send('Я тут, на Камчатке!')
@bot.command()
async def foo(ctx, *, arg):
await ctx.send(arg)
@bot.command()
async def Info(ctx):
await ctx.send('Я - Rest HOLL PJ - Игровой бот который следит за порядком')
@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 cat(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 Dog(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 Fox(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 Number(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
await bot.process_commands(message)
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandNotFound ):
await ctx.send(embed = discord.Embed(description = f' {ctx.author.name}, данной команды не существует.', color=0x0c0c0c))```
bot.run(TOKEN)