Answer the question
In order to leave comments, you need to log in
How to count how many users are online, offline, in total on the server, and display them in embed from the bot?
I recently started learning a new programming language for me "Python", and started with bots.
I wanted to make information about the server, by type:
But how much I fiddle around I can’t do it, then errors, then the code is not correct.
Full code: here
@bot.command()
async def time( ctx, user: discord.Member ):
youstatus = users[str(member.status)]
all_online_server = ctx.guild.member_count
emb = discord.Embed( title = 'Информация:', description = 'Beta 0.0.8' , colour = discord.Color.green(), url = 'https://coderoffline.pw' )
emb.add_field( name = "На сервере:", value = ctx.guild.member_count , inline=True)
emb.add_field( name = "Status", value = ctx.guild.member_status )
emb.add_field( name = "Не в сети:", value = ctx.guild.member_count , inline=True)
emb.set_footer( text = ctx.author.name, icon_url = ctx.author.avatar_url )
#emb.set_image( url = 'https://coderoffline.pw/img/logo-white.png' )
#emb.set_thumbnail( url = 'https://coderoffline.pw/img/logo-white.png' )
now_date = datetime.datetime.now()
#emb.add_field( name = 'Онлайн:', value = (all_online_server 'человека' )
#emb.add_field( name = 'Time', value = 'Time: {}'.format( now_date ) )
await ctx.send( embed = emb )
bot.run(settings['token']) # Обращаемся к словарю settings с ключом token, для получения токена
Traceback (most recent call last):
File "C:\Users\skreb\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 902, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\skreb\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 856, in invoke
await self.prepare(ctx)
File "C:\Users\skreb\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 790, in prepare
await self._parse_arguments(ctx)
File "C:\Users\skreb\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 697, in _parse_arguments
transformed = await self.transform(ctx, param)
File "C:\Users\skreb\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 542, in transform
raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: user is a required argument that is missing.
Answer the question
In order to leave comments, you need to log in
and started with bots
https://qna.habr.com/answer?answer_id=1880941#answ...
https://qna.habr.com/answer?answer_id=1649941#answ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question