dartcord_core 0.3.1 copy "dartcord_core: ^0.3.1" to clipboard
dartcord_core: ^0.3.1 copied to clipboard

Dartcord makes it easy to create discord bots using the Dart programming language

example/README.md

Dartcord examples #

⚠️ PLEASE NOTE

More examples are coming soon

Hello command #

import 'package:dartcord_core/dartcord_core.dart';

const String token = "token";

void onMessage(Message message) async {
  if (message.author.isBot) return;

  if (message.content == "!hello") {
    return await message.reply("Hello!");
  }
}

void main() async {
  Client c = Client();

  c.onReady((User user) {
    print("${user.username} is online!");
  });
  c.onMessage(onMessage);

  c.login(token);
}

MessageEmbed example #

import 'package:dartcord_core/dartcord_core.dart';

const String token = "token";

void onMessage(Message message) async {
  if (message.author.isBot) return;

  MessageEmbed embed = MessageEmbed(
    author: MessageEmbedAuthor.fromUser(message.author),
    color: 0xa2e66e, // Color code in hex fomat
    description: "A simple example of an MessageEmbed",
    title: "Example Embed",
    fields: [
      MessageEmbedTextField(name: "User", value: message.author.username),
      MessageEmbedTextField(
          name: "Guild name", value: message.channel.guild!.name),
    ],
  );

  if (message.content == "!embed") {
    return await message.reply(null, [embed]);
  }
}

void main() async {
  Client c = Client();

  c.onReady((User user) {
    print("${user.username} is online!");
  });
  c.onMessage(onMessage);

  c.login(token);
}
9
likes
120
points
50
downloads

Publisher

verified publishersjensen.dev

Weekly Downloads

Dartcord makes it easy to create discord bots using the Dart programming language

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

http, web_socket_channel

More

Packages that depend on dartcord_core