[Python] Discord.py not responding

Discussão em 'Python' iniciado por Stack, Novembro 25, 2024.

  1. Stack

    Stack Membro Participativo

    I wanted to try adding / commands to my bot but for some reason it allways tells me the errormessage "Couldnt react in time" in discord why is this happening

    import discord
    import os
    from discord.ext import commands
    from discord import app_commands, Interaction

    BOT_TOKEN = 'mycode'

    # Create bot instance with intents
    intents = discord.Intents.default()
    intents.message_content = True
    bot = commands.Bot(command_prefix='.', intents=intents)

    # Define slash command arguments
    @bot.tree.command(name='test', description='Gibt es monkeys')
    async def test(interaction: Interaction):
    response = f"Received: Hallo"
    await interaction.response.send_message(response)

    @bot.event
    async def on_ready():
    try:
    print(f'Signed in as {bot.user}')
    await bot.tree.sync() # Sync slash commands
    print(f"Successfully synced commands.")
    except Exception as e:
    print(f"Error syncing commands: {e}")

    @bot.command()
    async def Test(ctx):
    await ctx.send("test")

    # Run the bot
    bot.run(BOT_TOKEN)

    Continue reading...

Compartilhe esta Página