[Python] Discord bot not responding to commands

Discussão em 'Python' iniciado por Stack, Maio 28, 2025.

  1. Stack

    Stack Membro Participativo

    I tried to change the syntax, maybe there are problems with it, but it didn't work. I don't understand at all what my problem is because I am a beginner.

    The bot simply does not respond and does not react at all.

    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('Couldn\'t find the article.')

    @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('Couldn\'t find the video.')

    bot.run('TOKEN')

    Continue reading...

Compartilhe esta Página