При использовании команды D.add "аргумент1" вылезает данная ошибка:
spoilerMicrosoft Windows [Version 6.3.9600]
(c) Корпорация Майкрософт (Microsoft Corporation), 2013. Все права защищены.
C:\Users\User>python "Desktop\для проекта\main.py"
C:\Users\User\Desktop\для проекта\main.py:11: RuntimeWarning: coroutine 'Command
.__call__' was never awaited
print('We have logged in as {0.user}'.format(client))
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Ignoring exception in command add:
Traceback (most recent call last):
File "C:\Users\User\AppData\Roaming\Python\Python310\site-packages\discord\ext
\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\User\AppData\Roaming\Python\Python310\site-packages\discord\ext
\commands\core.py", line 855, in invoke
await self.prepare(ctx)
File "C:\Users\User\AppData\Roaming\Python\Python310\site-packages\discord\ext
\commands\core.py", line 789, in prepare
await self._parse_arguments(ctx)
File "C:\Users\User\AppData\Roaming\Python\Python310\site-packages\discord\ext
\commands\core.py", line 706, in _parse_arguments
kwargs[name] = await self.transform(ctx, param)
File "C:\Users\User\AppData\Roaming\Python\Python310\site-packages\discord\ext
\commands\core.py", line 542, in transform
raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: content is a required argum
ent that is missing.
при создании команды использовались открытые источники
import json
import discord
from discord.ext import commands
from datetime import datetime
data = {'1':2,'2':3,'3':'Desktop/users.json'}
json.dump(data, open("Desktop/users.json","w",encoding="utf8"),ensure_ascii=False)
client = discord.ext.commands.Bot(command_prefix = "D.")
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.command()
async def add(ctx, *, content:str):
with open("Desktop/users.json","r") as f:
data = json.load(f)
data.append(content)
with open("Desktop/users.json","w") as f:
json.dump(data, f)
@client.command()
async def read(ctx, *, text):
with open("Desktop/users.json","r") as f:
data = json.load(f)
await ctx.send(f'{data}')
@client.command()
async def print(ctx):
now = datetime.now()
s = now.time()
await ctx.send(f'{s}')
@client.command()
async def print1(ctx):
await ctx.send(f"```lol```")
@client.command()
async def prindt(ctx,arg1,arg2,arg3):
a = arg1
b = arg2
c = arg3
if (b) == "*" :
a = int(a) * int(c)
else:
if (b) == "+":
a = int(a) + int(c)
else:
if (b) == "-":
a = int(a) + int(c)
else:
if (b) == "/":
a = int(a) / int(c)
await ctx.send(f'{int(a)}')
client.run('MyToken')