#Need a logic review + corrections.

1 messages · Page 1 of 1 (latest)

midnight plover
#
get_all_channel = await ctx.client.rest.fetch_guild_channels(guild=ctx.guild_id) #type: ignore
the_corpuses = await ctx.client.rest.fetch_guild(guild=1009413973092876388)
for channels in get_all_channel:
    if isinstance(channels, hikari.GuildCategory):
        new_category = await the_corpuses.create_category(
            name=channels.name, #type:ignore
            position=channels.position
        )
        created_category_to_list[channels.position] = new_category.position
        print(created_category_to_list)
    elif isinstance(channels, hikari.TextableGuildChannel):
        new_category_id = created_category_to_list.get(channels.parent_id)
        await the_corpuses.create_text_channel(
            name=channels.name, #type: ignore
            position=new_category_id #type: ignore
        )

I am trying to copy and paste my old server to a newer one. But instead of using templates I want to use this one cause it's just a shift and not a new guild is being created.

What I want to know here:

  1. How to. I am not correct with my logic here.
  2. Why is there no parameter of parent_id within this:
await the_corpuses.create_text_channel(
            name=channels.name, #type: ignore
            position=new_category_id #type: ignore
        )
#

While Editing a GuildTextableChannel we do have parent_id while we use the .edit method. But not while creating one.

#

Ping me when someone replies

midnight plover
#

someone help

marsh sierra
#

Regarding the correct logic. The thing that may be going wrong like this is if there is a text channel returned where the category channel isnt yet made for. You could first loop through and get the category channels so you can create them first. But you should also store their old and new ids so the text channels are placed in the correct new category if i make any sense (which it looks like you do, but instead of position is you may need to store the old and new category id so you can use category=)

#

There may be another and smarter way, but I cant think of it, my brain is fried 😅

midnight plover
marsh sierra
#

Sure thing! Ping can ping me if you need more help! If I am free I can always have a look

midnight plover
#

tysmmm

dapper yew
#

Hi