tn_discord 1.2.0 copy "tn_discord: ^1.2.0" to clipboard
tn_discord: ^1.2.0 copied to clipboard

A powerful Dart library for interacting with the Discord API.

example/main.dart

import 'package:tn_discord/src/classes/events.dart';
import 'package:tn_discord/src/classes/message/message.dart';
import 'package:tn_discord/src/classes/message/message_sent.dart';
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
    ])
  );

  client.login("Your Bot Token");

  client.on("READY", (data) async {
    // Let we get a guild name
    var a = await client.guilds.fetch("a guild id");
    print(a.name);
  });

  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));
    }
  });
}
1
likes
130
points
82
downloads

Documentation

API reference

Publisher

verified publisherthundernetwork.org

Weekly Downloads

A powerful Dart library for interacting with the Discord API.

Repository (GitHub)
View/report issues

License

Apache-2.0 (license)

Dependencies

events_emitter, http

More

Packages that depend on tn_discord