I recently program with discord.py and after several searches I still can't find a way to implement this command (it also leads me to have problems with other commands that request information from the server) and therefore I need help if you can. In this case I want to create a command that gives me the server information.
Traceback (most recent call last):
File "C:\Users\PC GIUSEPPE\PycharmProjects\untitled\venv\lib\site-packages\discord\ext\commands\bot.py", line 892, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\PC GIUSEPPE\PycharmProjects\untitled\venv\lib\site-packages\discord\ext\commands\core.py", line 797, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\PC GIUSEPPE\PycharmProjects\untitled\venv\lib\site-packages\discord\ext\commands\core.py", line 92, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'server' is not defined
Code:
@client.command(aliases=["serverinfo","Server_info","Serverinfo","SERVERINFO","si","Si","SI"])
@commands.has_any_role('Moderatori', 'Triumvirato', 'Co-Triumvirato', 'Senatori', '690956686147453048')
async def ServerInfo(ctx):
author = ctx.author.name
name_server = server.name
create_server = server.create
owner_server = server.owner.name
embed = discord.Embed(
title="Informazioni del server",
description=f'Tutte le informazioni generali del nostro server {name_server}',
color=0x003399
)
embed.set_thumbnail(url='')
embed.set_footer(text=f'Richiesto da: {author}')
embed.add_field(
name='Server creato il:',
value='f{create_server}',
)
embed.add_field(
name='Owner Attuale del server:',
value='f{create_server}',
)
embed.add_field(
name='Server creato il:',
value=f'{create_server}',
)
embed.add_field(
name='Server creato il:',
value=f'{owner_server}',
)