DSharpPlus/Entities/Channel/Message/DiscordMessageBuilder.cs
/// <summary>
/// Sets if the message has files to be sent.
/// </summary>
/// <param name="files">The Files that should be sent.</param>
/// <param name="resetStreamPosition">Tells the API Client to reset the stream position to what it was after the file is sent.</param>
/// <returns></returns>
Sets if the message has files to be sent.
Sets if the message has files to be sent .
public DiscordMessageBuilder WithFiles(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 DiscordMessageBuilder WithFiles ( 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 ; }
Sets if the message has files to be sent.
Sets if the message has files to be sent .
None
files
Dictionary<string, Stream>
The Files that should be sent.
The Files that should be sent .
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 .