DSharpPlus/Entities/DiscordWebhookBuilder.cs
/// <summary>
/// Adds the given files to send at the execution of the webhook.
/// </summary>
/// <param name="files">Dictionary of file name and file data.</param>
/// <param name="resetStreamPosition">Tells the API Client to reset the stream position to what it was after the file is sent.</param>
Adds the given files to send at the execution of the webhook.
Adds the given files to send at the execution of the webhook .
public DiscordWebhookBuilder AddFiles(Dictionary<string, Stream> files, bool resetStreamPosition = false)
        {
            if (this.Files.Count() + files.Count() >= 10)
                throw new ArgumentException("Cannot send more than 10 files with a single message.");
            foreach (var file in files)
            {
                if (this._files.Any(x => x.FileName == file.Key))
                    throw new ArgumentException("A File with that filename already exists");
                if (resetStreamPosition)
                    this._files.Add(new DiscordMessageFile(file.Key, file.Value, file.Value.Position));
                else
                    this._files.Add(new DiscordMessageFile(file.Key, file.Value, null));
            }
            return this;
        }
public DiscordWebhookBuilder AddFiles ( Dictionary < string , Stream > files , bool resetStreamPosition = false ) { if ( this . Files . Count ( ) + files . Count ( ) >= 10 ) throw new ArgumentException ( " " ) ; foreach ( var file in files ) { if ( this . _files . Any ( x => x . FileName == file . Key ) ) throw new ArgumentException ( " " ) ; if ( resetStreamPosition ) this . _files . Add ( new DiscordMessageFile ( file . Key , file . Value , file . Value . Position ) ) ; else this . _files . Add ( new DiscordMessageFile ( file . Key , file . Value , null ) ) ; } return this ; }
Adds the given files to send at the execution of the webhook.
Adds the given files to send at the execution of the webhook .
files
Dictionary<string, Stream>
Dictionary of file name and file data.
Dictionary of file name and file data .
resetStreamPosition
bool
Tells the API Client to reset the stream position to what it was after the file is sent.
Tells the API Client to reset the stream position to what it was after the file is sent .