La discordia bot no vaya en línea

0

Pregunta

Acabo de empezar a aprender python y mi discordia bot no ir en línea. se acaba de decir "El proceso de salida con el código de salida 0". Y no hay ningún error con el código.

aquí está mi código. introduzca la descripción de la imagen aquí

discord discord.py python
2021-11-23 04:23:03
3
0

Agregar await client.process_commands(ctx) y @client.event no necesita paréntesis(). Utilice el código siguiente:

@client.event
async def on_message(ctx):
  if ctx.author == client.user:
    return

  await client.process_commands(ctx)

Utilice este código completo si aún así no funciona:

import discord
from discord.ext import commands

bot = commands.Bot(command_prefix="!")


@bot.event
async def on_ready():
  print('We are logged in!')

@bot.event
async def on_message(message):
   if message.author==bot.user: 
     return

   await bot.process_commands(message)

@bot.command()
async def ping(message) :
   await message.channel.send("Pong!!")

bot.run("TOKEN")
2021-11-23 05:57:23

Gracias, Pero el bot aún sin conexión.
Shir0

He editado mi post para que todo el código a probar esto.
Siddhant Chauhan

Aún así no funciona. No hay ningún error en el código y después corrí el programa se acaba de decir" proceso terminado con código de salida 0".
Shir0

Eso significa que no hay error en el código, pero usted tiene que echa un vistazo en los ajustes de tu IDE : stackoverflow.com/a/61883867/16203851
Siddhant Chauhan
0

Usted debe intentar este lugar

import os
import discord
from discord.ext import commands

discord_token = "Your Token"

client = discord.Client()

bot = commands.Bot(cloient_prefix="!")

@client.command()
async def on_ready():
  print("running")

other codes here...

bot.run(discord_token)
2021-11-23 05:19:54
-1

El código que usted le dio es incorrecto, esto es correcto:

import os 
import discord
from discord.ext import commands

bot = commands.Bot(command_prefix="!") # you don't need an extra discord.client Bot is enough
token = os.getenv("TOKEN")
#you should not run the program here you should run it at last

@bot.event #no need for brackets
async def on_ready():
  print("running")

@bot.event
async def on_message(ctx):
  if ctx.author == client.user:
    return

@bot.command(name="span",description="YOUR DESCRIPTION HERE") # it is command and not commands
async def span_(ctx,amount:int,*,message):
  for i in range(amount):
    await ctx.send(message)

bot.run(token) #you should run the bot now only and this will work perfectly!

Usted puede encontrar la documentación para discord.py aquí.

2021-11-23 06:00:41

Gracias, pero el bot aún sin conexión. No hay ningún error encontrado
Shir0

usted debe tener una.env archivo esta el token o de lo contrario este no funciona
DevER-M

En otros idiomas

Esta página está en otros idiomas

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Slovenský
..................................................................................................................