Svár bot nepůjde online

0

Otázka

Právě jsem se začal učit python a můj svár bot nebude jít on-line. to jen řekl "Proces ukončit s návratový kód 0". A tam je žádná chybová s kódem.

tady je můj kód. zadejte popis obrázku zde

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

Přidat await client.process_commands(ctx) a @client.event nepotřebujeme závorky(). Použijte kód níže:

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

  await client.process_commands(ctx)

Použít celý tento kód, pokud to stále nefunguje:

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

Díky, Ale bot stále offline.
Shir0

Jsem upravil můj příspěvek celý kód, zkuste to.
Siddhant Chauhan

To stále nefunguje. Není chyba v kódu a potom, co jsem narazil na programu, to prostě řekl," process skončil s kódem ukončení 0".
Shir0

To znamená, že není chyba v kódu, ale budete muset zkontrolovat v nastavení vašeho IDE : stackoverflow.com/a/61883867/16203851
Siddhant Chauhan
0

Měli byste se pokusit to místo

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

Kód, který jste dal je špatné, toto je správné:

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!

Můžete najít dokumentaci pro discord.py tady.

2021-11-23 06:00:41

Díky, ale bot stále offline. Nenalezena žádná chyba
Shir0

měli byste mít.env soubor tohoto tokenu, jinak to nebude pracuje
DevER-M

V jiných jazycích

Tato stránka je v jiných jazycích

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