Я пробую создавать простого бота для дискорд через библиотеку discord.py и при запуске у меня вылетает такая ошибка:
RuntimeError: Cannot close a running event loop
Код:
token = '-'
administrator = []
prefix = '#'
bot = commands.Bot(command_prefix=prefix)
@bot.event
async def on_ready():
print("I'm start!")
await bot.change_presence(activity=discord.Game(name=f'{prefix}help'))
@bot.command()
async def embed(ctx):
embed = discord.Embed(
title = 'msg',
description = 'msg'
)
await ctx.send(embed=embed)
@bot.command()
async def msg(ctx, arg):
if arg == 'test':
await ctx.send('TEST')
await ctx.message.delete()
@bot.command()
async def chcreate(ctx, count):
if int(ctx.author.id) in administrator:
for i in range(int(count)):
create = 0
try:
await ctx.guild.create_text_channel('Just for FUN!')
await ctx.message.add_reaction(':bomb:')
except:
print('Channe is not create.')
else:
create += 1
embed = discord.Embed(
title = 'Channel is create!',
description = 'How are you?'
)
await ctx.author.send(embed=embed)
bot.run(token)