Discordia bot non andare online

0

Domanda

Ho appena iniziato a imparare python e il mio discordia bot non andare online. è appena detto "Il processo di uscita con codice di uscita 0". E non c'è nessun errore con il codice.

ecco il mio codice. inserire immagine qui la descrizione

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

Aggiungere await client.process_commands(ctx) e @client.event non hanno bisogno di parentesi(). Utilizzare il codice indicato di seguito:

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

  await client.process_commands(ctx)

Utilizzare questo codice intero, se ancora non funziona:

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

Grazie, Ma il bot è ancora offline.
Shir0

Ho modificato il mio post per intero codice di provare questo fuori.
Siddhant Chauhan

Ancora non funziona. Non c'è alcun errore nel codice e dopo ho eseguito il programma è appena detto" processo completato con codice di uscita 0".
Shir0

Che significa che non c'è nessun errore nel codice, ma devi controllare nelle impostazioni del vostro IDE : stackoverflow.com/a/61883867/16203851
Siddhant Chauhan
0

Si dovrebbe provare questo invece

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

Il codice che hai dato è sbagliato, questo è corretto:

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!

È possibile trovare la documentazione per discord.py qui.

2021-11-23 06:00:41

Grazie, ma il bot è ancora offline. Nessun errore trovato
Shir0

si dovrebbe avere un.env file questo il token o altro questo solito funziona
DevER-M

In altre lingue

Questa pagina è in altre lingue

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