Dhsarpplus: how can i change the channel permissions

39 Views Asked by At

I need your help with something:

 [SlashCommand("addUser", "Creates a dedicated Room with the specified Users Name")]
            [Obsolete]
            public async Task addUser(InteractionContext ctx, [Option("Username", "select the user you want to add")] DiscordUser user)
            {
                ulong categoryID = 1171607239413473300;

               
                if (user is DiscordMember member)
                {
                    DiscordOverwriteBuilder permission = new DiscordOverwriteBuilder()
                        .For(member)
                        .Allow(Permissions.SendMessages);

                        DiscordChannel category = ctx.Guild.GetChannel(categoryID);

                    if (category != null)
                    {
                        DiscordChannel room = await category.Guild.CreateTextChannelAsync(
                            $"{user.Username}",
                            category,
                            $"{user.Username} Private Room!",
                            overwrites: new List<DiscordOverwriteBuilder> { permission }
                        );

                        await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder()
                            .WithContent($"Room Created!: {room.Mention}")
                            .AsEphemeral(true));
                    }
                    else
                    {
                        await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder()
                            .WithContent("The specified category was not found.")
                            .AsEphemeral(true));
                    }
                }
                else
                {
                    
                    await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder()
                        .WithContent("This User is not member.")
                        .AsEphemeral(true));
                }
            }

I'm trying to do what it says here in the description but I can't get it right.

I got help from Chatgpt, I browsed the forums but I couldn't do it.

0

There are 0 best solutions below