나는 그냥 시작한 배우 python 및 내 불화 로봇지 않습니다. 그것은 단지 말 "프로세스를 종료와 함께 출구호 0". 이 없다는 오류 코드입니다.
여기 나의 코드입니다. 입력한 이미지는 여기에 설명
나는 그냥 시작한 배우 python 및 내 불화 로봇지 않습니다. 그것은 단지 말 "프로세스를 종료와 함께 출구호 0". 이 없다는 오류 코드입니다.
여기 나의 코드입니다. 입력한 이미지는 여기에 설명
추가 await client.process_commands(ctx)
고 @client.event
이 필요하지 않 괄호()
. 코드를 사용하여 아래와 같습니다:
@client.event
async def on_message(ctx):
if ctx.author == client.user:
return
await client.process_commands(ctx)
이 전체 코드의 경우 그것은 여전히 작동하지 않:
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")
당신이 대신
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)
코드에 당신은 잘못이 정확:
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!
당신을 찾을 수 있습니다에 대한 설명서 discord.py 여기에.