AttachmentBuilder.file constructor
Create an attachment from a path
await interaction.reply(
content: 'Hello World!',
attachments: [AttachmentBuilder.file('assets/hello.png', description: 'Idk']
);
You can integrate image in embeds :
await interaction.reply(
content: 'Hello World!',
attachments: [AttachmentBuilder.file('assets/hello.png', description: 'Idk'],
embeds: [EmbedBuilder(title: 'How are you?', thumbnail: Thumbnail(url: 'attachment://hello.png'))]
);
Implementation
factory AttachmentBuilder.file(String path, {String? description, String? overrideFilename}) {
File file = File(join(Directory.current.path, path));
return AttachmentBuilder(file.readAsBytesSync(), filename: basename(file.path), description: description);
}