I am trying to create a function that first creates a category called "management", then it creates a channel named after the member count of my server.
The expected outcome is that the category and channel gets created accordingly as explained above.
This is the code i am trying to use
@client.command()
async def setup_counter(ctx):
try:
await ctx.send("Setting up management!")
await guild.create_category("Management", overwrites=None, reason=None)
await guild.create_voice_channel(f"Member Count: {guild.member_count}", overwrites=None, category="Management", reason=None)
await ctx.send("Setup finished!")
except Exception as errors:
print(f"Bot Error: {errors}")
You need to select on which server (Guild) you want to do that. Additonally you need to pass a reference to the category not just the name of it. If you know the id of your guild, use this:
@client.command()
async def setup_counter(ctx):
try:
guild = client.get_guild(id) # <-- insert yor guild id here
await ctx.send("Setting up management!")
category = await guild.create_category("Management", overwrites=None, reason=None)
await guild.create_voice_channel(f"Member Count: {guild.member_count}", overwrites=None, category=category, reason=None)
await ctx.send("Setup finished!")
except Exception as errors:
print(f"Bot Error: {errors}")
If you dont know the guild id just follow this official article where they discuss finding the server id.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With