DSharpPlus/Clients/DiscordClient.cs
/// <summary>
/// Creates a guild from a template. This requires the bot to be in less than 10 guilds total.
/// </summary>
/// <param name="code">The template code.</param>
/// <param name="name">Name of the guild.</param>
/// <param name="icon">Stream containing the icon for the guild.</param>
/// <returns>The created guild.</returns>
/// <exception cref="Exceptions.BadRequestException">Thrown when an invalid parameter was provided.</exception>
/// <exception cref="Exceptions.ServerErrorException">Thrown when Discord is unable to process the request.</exception>
Creates a guild from a template. This requires the bot to be in less than 10 guilds total.
Creates a guild from a template . This requires the bot to be in less than 10 guilds total .
public Task<DiscordGuild> CreateGuildFromTemplateAsync(string code, string name, Optional<Stream> icon = default)
        {
            var iconb64 = Optional.FromNoValue<string>();
            if (icon.HasValue && icon.Value != null)
                using (var imgtool = new ImageTool(icon.Value))
                    iconb64 = imgtool.GetBase64();
            else if (icon.HasValue)
                iconb64 = null;
            return this.ApiClient.CreateGuildFromTemplateAsync(code, name, iconb64);
        }
public Task < DiscordGuild > CreateGuildFromTemplateAsync ( string code , string name , Optional < Stream > icon = default ) { var iconb64 = Optional . FromNoValue < string > ( ) ; if ( icon . HasValue && icon . Value != null ) using ( var imgtool = new ImageTool ( icon . Value ) ) iconb64 = imgtool . GetBase64 ( ) ; else if ( icon . HasValue ) iconb64 = null ; return this . ApiClient . CreateGuildFromTemplateAsync ( code , name , iconb64 ) ; }
Creates a guild from a template.
Creates a guild from a template .
The created guild.
The created guild .
Thrown when an invalid parameter was provided.
Thrown when an invalid parameter was provided .
Thrown when Discord is unable to process the request.
Thrown when Discord is unable to process the request .
code
string
The template code.
The template code .
name
string
Name of the guild.
Name of the guild .
icon
Optional<Stream>
Stream containing the icon for the guild.
Stream containing the icon for the guild .