@Sad2Sage

Почему бот для дискорд не отвечает на команды?

Бот вроде запускается и находится в сети но на команды с префиксом (и без) не отвечает. Совсем уже не знаю что делать + я новичок в пайтон и сам понять не могу.

import discord
import googlesearch
import wikipedia
import youtube_search
import youtube_dl
import requests
import random
from discord import Embed
from discord.ext import commands

intents = discord.Intents.default()
bot = commands.Bot(command_prefix='JE.', intents=intents)

@bot.event
async def on_ready():
print(f'Logged in as {bot.user}')

@bot.command()
async def google(ctx, *, query):
search_results = googlesearch.search(query, num_results=5)
response = ''
for result in search_results:
response += f'{result}\n'
await ctx.send(response)

@bot.command()
async def wiki(ctx, *, query):
try:
search_results = wikipedia.search(query)
page = wikipedia.page(search_results[0])
embed = Embed(title=page.title, url=page.url, description=page.summary)
await ctx.send(embed=embed)
except:
await ctx.send('Не удалось найти статью.')

@bot.command()
async def youtube(ctx, *, query):
search_results = youtube_search.search(query, max_results=1)
if search_results:
video_url = f'https://www.youtube.com/watch?v={search_results[0]["id"]}'
embed = Embed(title=search_results[0]['title'], url=video_url, description=search_results[0]['description'])
await ctx.send(embed=embed)
else:
await ctx.send('Не удалось найти видео.')

bot.run('TOKEN')
  • Вопрос задан
  • 80 просмотров
Решения вопроса 1
Vindicar
@Vindicar
RTFM!
Проверь intents. Для классических команд (не слэш-команд) нужен интент messages=True.
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

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

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