J
J
Jasge2021-03-04 16:23:31
Python
Jasge, 2021-03-04 16:23:31

Discord.py bot won't start, how can I fix it?

import discord
from discord.ext import commands

token = "token"
bot = commands.Bot(command_prefix='-')


@bot.event
async def on_ready():
    print('here')


@bot.command(pass_context=True)
async def hi(ctx):
    await ctx.send('hi')
    bot.run(token)


After starting, it immediately stops, does not give any errors, only writes: Process finished with exit code 0.
The bot itself does not appear on the network for a second.
The token is worth it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kray74, 2021-03-04
@Jasge

The bot.run() call must be outside the hi function

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question