This repository has been archived on 2024-10-16. You can view files and clone it, but cannot push or open issues or pull requests.
discord-dart/example/main.dart

30 lines
860 B
Dart
Raw Normal View History

2023-08-08 16:59:38 +02:00
import 'package:tn_discord/tn_discord.dart';
main() async {
var client = Client(
intents: calculateIntents([
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent
// What do you want from GatewayIntentBits
])
);
2023-08-20 15:17:22 +02:00
client.login("ODkwMz1g");
2023-08-08 16:59:38 +02:00
client.on("READY", (data) async {
// Let we get a guild name
2023-08-20 15:16:21 +02:00
var a = await client.guilds.fetch("913388008307302410");
2023-08-08 16:59:38 +02:00
print(a.name);
2023-08-20 15:16:21 +02:00
client.commands.create(Command(name: "test", description: "test1"));
2023-08-08 16:59:38 +02:00
});
client.on(Events.MessageCreate, (MessageSent message) async {
// When a message is sent print author id and reply with the same message
print(message.authorID);
if (message.authorID != client.user.id) {
client.channels.cache.get(message.id).send(Message(content: message.content));
}
});
}