#Make new VC in category by ID

1 messages · Page 1 of 1 (latest)

runic stream
#

Hi, i want to create a new VC in a given category, but i get a AttributeError: 'int' object has no attribute 'id' error. The code i used:

        @bot.slash_command(description="Maak een support voice-kanaal aan!")
        async def support_voice(inter):
            guild = bot.get_guild(env_variable.GUILD_ID)
            await guild.create_voice_channel("test", category=979395372738818116)
            await inter.response.send_message("I workzz", ephemeral=True)```

Do i need to get the channel by name or?
snow silo
#

-d guild.create_voice_channel

warped owlBOT
#

await create_voice_channel(name, *, category=None, position=..., bitrate=..., user_limit=..., rtc_region=..., video_quality_mode=..., nsfw=..., slowmode_delay=..., overwrites=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

This is similar to [`create_text_channel()`](https://docs.disnake.dev/en/latest/api.html#disnake.Guild.create_text_channel "disnake.Guild.create_text_channel") except makes a [`VoiceChannel`](https://docs.disnake.dev/en/latest/api.html#disnake.VoiceChannel "disnake.VoiceChannel") instead.

Changed in version 2.6: Raises [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.11)") instead of `InvalidArgument`.
snow silo
#

Notice how it says category Optional[CategoryChannel]?

#

It expects a category object, not the ID of a category

next rover
#

you can also pass Object(<ID>)

#

that typehint is incorrect

runic stream
snow silo
#

disnake.Object(979395372738818116) would work in this case.

But if you need a full object, there are various methods.

Look into the docs for Bot and Guild to see the various get and fetch methods

runic stream
#

Hmm okey!

snow silo
#

For making bots you should have a fairly decent understanding of basic Python, with a hint of intermediate knowledge.

For instance, understanding classes and instances of classes is a pretty big part of OOP in general.

winged lake