I am creating autovc command for my discord bot but I ran into some error. Code:
@client.command()
async def autovc(ctx):
def check(message):
return message.author == ctx.author
await ctx.send("Please enter the channel name you want to create?")
c_name= await client.wait_for('message', check=check)
await ctx.send("What would be the channel user limit?")
c_limit= int((await client.wait_for('message', check=check)).content)
await ctx.send("Please Enter the Category ID in which tha channel will be created.")
guild = client.get_guild(852866665371926588)
ctg= discord.utils.get(guild.categories, id=(int((await client.wait_for('message', check=check)).content)))
await guild.create_voice_channel(name= c_name, category= ctg, user_limit= c_limit)
Error:
File "C:\Users\illus\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped ret = await coro(*args, **kwargs) File "d:\BOT\test.py", line 30, in autovc await guild.create_voice_channel(name= c_name, category= ctg, user_limit= c_limit)
File "C:\Users\illus\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\guild.py", line 987, in create_voice_channel data = await self.create_channel(name, overwrites, ChannelType.voice, category, reason=reason, **options) File "C:\Users\illus\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\http.py", line 156, in request kwargs['data'] = utils.to_json(kwargs.pop('json')) File "C:\Users\illus\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\utils.py", line 328, in to_json return json.dumps(obj, separators=(',', ':'), ensure_ascii=True) File "C:\Users\illus\AppData\Local\Programs\Python\Python39\lib\json_init.py", line 234, in dumps return cls( File "C:\Users\illus\AppData\Local\Programs\Python\Python39\lib\json\encoder.py", line 199, in encode chunks = self.iterencode(o, _one_shot=True) File "C:\Users\illus\AppData\Local\Programs\Python\Python39\lib\json\encoder.py", line 257, in iterencode return _iterencode(o, 0) File "C:\Users\illus\AppData\Local\Programs\Python\Python39\lib\json\encoder.py", line 179, in default raise TypeError(f'Object of type {o.class.name} '
TypeError: Object of type Message is not JSON serializable
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "C:\Users\illus\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke await ctx.command.invoke(ctx) File "C:\Users\illus\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke await injected(*ctx.args, **ctx.kwargs) File "C:\Users\illus\AppData\Local\Programs\Python\Python39\lib\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: TypeError: Object of type Message is not JSON serializable
async def autovc(ctx, c_name: str, c_categid: int, c_limit: int):