Discord 日志记录器?

GitHub stars

Follow Twitter

一个简单的 Flutter 包,通过 Discord 机器人将消息发送到 Discord 频道

用法

要使用此插件,请将 discord_logger 添加到您的 pubspec.yaml 文件中作为 依赖项 ?。

使用此包之前的步骤

  • 在 ? https://discord.com/developers/applications 创建新应用。

  • 在菜单中转到 OAuth2,然后转到 URL 生成器

  • 在表单中选择 applications.commandsbot

  • 目前,在 Bot Permissions 中授予管理员权限

  • 复制生成的 URL 并粘贴到浏览器的标签页中

  • 添加您想访问以发送消息(目前)的服务器,并完成该过程

您现在可以开始使用了 ?

初始化 [DiscordLogger]

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {

    DiscordLogger(
      channelId: "[Add Your Channel Id]",
      botToken: "[Add Your Bot Token]",
    );

    return MaterialApp(
      ...
    );
  }
}

如何获取 Channel ID 和 Bot Token?

Add Bot

  • 重置 Token 以获取 Token

Get Bot Token

  • 复制 token 并添加到 botToken 参数

创建 DiscordLogger 实例

final discord = DiscordLogger.instance;

发送消息

...

discord.sendMessage("This is a error log to my channel");

...

? 贡献者


?.

GitHub

查看 Github