#Allow users with moderation permissions to see specific channel

1 messages · Page 1 of 1 (latest)

errant scaffold
#

Im writing a Ticket system for my Discord server at the moment, and im attempting to add all roles with moderation permissions to the channel
this is my current code:

public async static ITextChannel CreateTicketChannel(InteractionModuleBase interaction)
{
  ITextChannel channel = await interaction.Context.Guild.CreateTextChannelAsync(Guid.NewGuid().ToString(), c => c.CategoryId = Utils.ChannelConfig["ticket_category"]);
  await channel.AddPermissionOverwriteAsync(interaction.Context.Guild.EveryoneRole, OverwritePermissions.DenyAll(channel));
  await channel.AddPermissionOverwriteAsync(/* This is where its supposed to pick roles with moderation permissions*/, OverwritePermissions.AllowAll(channel));
  await channel.AddPermissionOverwriteAsync(interaction.Context.User, OverwritePermissions.AllowAll(channel));
  return channel;
}
light cosmos
errant scaffold
# light cosmos

my code is an amalgamation of holy words, cyphers of the old Gods and the fundamental math that hold this universe together

light cosmos
#

so

#

the thing is

#

you see that Action<TextChannelProperties>

#

it inherits GuildChannelProperties

#

which have this:

#

so you just do this

#

and make a channel with all the overwrites with a single api call

errant scaffold
#

ah

light cosmos
#

and to get all roles => interaction.Context.Guild.Roles.Where(x => x.Permissions.Something)

errant scaffold
#

bet

#

thanks