DSharpPlus How to create or set a discord channel to NSFW in C#

1.8k Views Asked by At

PS: Sorry for my bad english, it not my first language

I'm creating a public discord bot with DSharpPlus in c#. I know how to create channels(voice/text/category), set their roles/users permissions and figure out if a text channel is NSFW or not.

However, I don't know how to create a NSFW channel (or make a channel NSFW).

I was thinking that maybe it can be set with the class DiscordOverwrite, so I search in some documentations and found DSharp​Plus.​Entities.DiscordOverwriteBuilder, but the class doesn't exist in the DSharpPlus package that I have.

In conclusion, how do I make a NSFW text channel (with code and not manually)?

try
{
    var result = await ctx.Guild.CreateChannelAsync(sName, DSharpPlus.ChannelType.Text, null, null, null, new List<DiscordOverwrite>());
    await ctx.Channel.SendMessageAsync($"**Le salon NSFW '{result.Name}' à été créer**\n__Salon créer: {result.Mention}__").ConfigureAwait(false);
}
catch (Exception)
{
    // Send error msg
    Util.SendMsg(ref ctx, Util.MessagesPreFaits.AucunSalonCréer, null, Util.EmbedType.Erreur);
    throw;
}
2

There are 2 best solutions below

2
On

You will have to use the nightly build in order to get the functionality: https://nuget.emzi0767.com/gallery/packages

0
On
var result = await ctx.Guild.CreateChannelAsync(sName, DSharpPlus.ChannelType.Text, null, null, null, new List<DiscordOverwrite>(), true);

TIP: Hover over CreateChannelAsync to see all the available parameters.