From 2764ef6aec254b85290ee17eb97d378464b28021 Mon Sep 17 00:00:00 2001 From: Rapougnac Date: Thu, 25 Apr 2024 08:47:36 +0200 Subject: [PATCH] Add example --- example/example.dart | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/example/example.dart b/example/example.dart index eb12212..298b307 100644 --- a/example/example.dart +++ b/example/example.dart @@ -24,7 +24,7 @@ void main() async { // Sanitizing content makes it safe to send to Discord without triggering any mentions client.onMessageCreate.listen((event) async { if (event.message.content.startsWith('!sanitize')) { - event.message.channel.sendMessage(MessageBuilder( + await event.message.channel.sendMessage(MessageBuilder( content: 'Sanitized content: ${await sanitizeContent(event.message.content, channel: event.message.channel)}', )); } @@ -67,5 +67,15 @@ ullamcorper morbi tincidunt ornare. } }); + client.onMessageCreate.listen((event) async { + if (event.message.content.startsWith('!avatar') && event.message.mentions.isNotEmpty) { + // Display the first mentioned user's avatar with the specified size. + final user = event.message.mentions.first; + await event.message.channel.sendMessage(MessageBuilder( + content: 'Avatar URL: ${user.avatar.get(format: CdnFormat.jpeg, size: 3072)}', + )); + } + }); + // ...and more! }