I want the bot to create a file it is not doing that in
f = open(f"json/guilds/db-gc/{name}.json", 'w')
print("{\"words\":[]}", file = f)
This Line Please Help me
@client.command()
async def chat_filter(ctx, val = None):
guild = ctx.guild
with open(f"json/guilds/config.json", "r") as f:
load = json.load(f)
if guild.id in load["ids"]:
print("The Guild Is Registerred")
elif not guild.id in load["ids"]:
name = ctx.guild.id
name = str(float(name))
id = str(guild.id)
f = open(f"json/guilds/db-gc/{name}.json", 'w')
print("{\"words\":[]}", file = f)
with open(f"json/guilds/config.json", "r") as f:
l = json.load(f)
l["ids"].append(ctx.guild.id)
with open(f"json/guilds/config.json", "w") as f:
json.dump(l, f)
else:
raise Exception("Some Error")
Error
Ignoring exception in command chat_filter:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 52, in chat_filter
f = open(f"json/guilds/db-gc/{name}.json", 'w')
FileNotFoundError: [Errno 2] No such file or directory: 'json/guilds/db-gc/8.205884699055227e+17.json'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: FileNotFoundError: [Errno 2] No such file or directory: 'json/guilds/db-gc/8.205884699055227e+17.json'
The bot is not really creating the file in that line please help me if you guys cam i will be really thankfull to you
Thankyou