Discordie bot nu va merge on-line

0

Problema

Am început să învăț python și mi discordie bot nu va merge on-line. ea doar a spus "Procesul de ieșire cu codul de ieșire 0". Și nu există nici o eroare cu codul.

aici e codul meu. introduceți descrierea imaginii aici

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

Adauga await client.process_commands(ctx) și @client.event nu ai nevoie de paranteze(). Folosiți codul de mai jos:

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

  await client.process_commands(ctx)

Utilizați întregul cod cazul în care încă nu funcționează:

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

Multumesc, Dar bot încă offline.
Shir0

Am editat postul meu la întregul cod încerca acest lucru.
Siddhant Chauhan

Încă nu funcționează. Nu există nici o eroare în cod și, după ce am fugit programul scria doar" proces terminat cu codul de ieșire 0".
Shir0

Asta înseamnă că nu există nici o eroare în cod, dar va trebui să verificați în setările IDE : stackoverflow.com/a/61883867/16203851
Siddhant Chauhan
0

Ar trebui să încercați acest loc

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

Codul-ai dat este greșit, acest lucru este corect:

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!

Puteți găsi documentația pentru discord.py aici.

2021-11-23 06:00:41

Multumesc, dar bot încă offline. Nu a fost găsit de eroare
Shir0

ar trebui să ai.env fișierul acest token-ul sau altceva asta nu funcționează
DevER-M

În alte limbi

Această pagină este în alte limbi

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