Skip to content

Commit 8704409

Browse files
committed
docs: add example main file
1 parent c04b6c4 commit 8704409

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

example/main.dart

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import 'package:mineral/api.dart';
2+
3+
void main(_, dynamic port) async {
4+
final client = ClientBuilder()
5+
.setHmrDevPort(port)
6+
.setIntent(Intent.allNonPrivileged)
7+
.build();
8+
9+
// Simple command - just 4 lines!
10+
client.commands.declare((cmd) => cmd
11+
..setName('hello')
12+
..setDescription('Say hello')
13+
..setHandle(
14+
(ctx) {
15+
final message = MessageBuilder.text('👋 Hello from Mineral!');
16+
17+
final mineralLinkButton = Button.link(
18+
'https://mineral-dart.dev/',
19+
emoji: PartialEmoji.fromUnicode('📘'),
20+
label: 'Check our documentation',
21+
);
22+
message.addButton(mineralLinkButton);
23+
24+
return ctx.interaction.reply(
25+
builder: message,
26+
);
27+
},
28+
));
29+
30+
await client.init();
31+
}

0 commit comments

Comments
 (0)