Rozbroje topánok nebude ísť on-line

0

Otázka

Práve som sa začal učiť python a moje rozbroje topánok nebude aktivovaná online. to len povedal "Proces ukončiť s exit kód 0". A nie je žiadna chyba s kódom.

tu je môj kód. zadajte popis obrázku tu

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

Pridať await client.process_commands(ctx) a @client.event nemusíte zátvorke(). Použiť kód uvedený nižšie:

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

  await client.process_commands(ctx)

Použite tento celý kód, ak 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

Vďaka, Ale topánok off-line.
Shir0

Som upravili svoj príspevok na celý kód, skús sa na to.
Siddhant Chauhan

Je stále nefunguje. Nie je chyba v kóde a potom som bežal program, je len povedal:" proces skončil s exit kód 0".
Shir0

To znamená, že nie je chyba v kóde, ale budete musieť vyskúšať v nastaveniach vášho IDE : stackoverflow.com/a/61883867/16203851
Siddhant Chauhan
0

Mali by ste skúsiť tento namiesto

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 ste poskytli je nesprávne, je to správne:

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 nájsť v dokumentácii discord.py tu.

2021-11-23 06:00:41

Vďaka, ale topánok off-line. Žiadne chyby nájdené
Shir0

mali by ste mať.env súbor tento token, inak to nebude funguje
DevER-M

V iných jazykoch

Táto stránka je v iných jazykoch

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