I was writing a simple function on discord.py
I had tried online databases to host the bot
import discord
from discord.ext import commands
from replit import db
client = discord.Client()
bot = commands.Bot(">", case_insensitive = True)
db['Plaksha'] = {'Server_Specific_Stuff':{'Channel for commands':0}}
chan_for_commands = 1
@bot.command()
async def set_commands_channel(ctx):
global chan_for_commands
print(chan_for_commands)
temp = ctx.message.channel
db['Plaksha']['Server_Specific_Stuff']['Channel for commands'] = temp
chan_for_commands = temp
print(chan_for_commands)
pass
token = ""
bot.run(token)
This function is supposed to update the variable chan_for commands. I had tried other clients other than Replit.com and it does not work!
Is there a way to escape this error? If so is there another way to update chan_for_commands both locally and in the online db (data base)?
The error says:
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: ValueError: Circular reference detected