agent-messenger 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/commands/release.md +92 -0
- package/.claude-plugin/README.md +144 -0
- package/.claude-plugin/marketplace.json +37 -0
- package/.claude-plugin/plugin.json +17 -0
- package/.github/workflows/ci.yml +30 -0
- package/CLAUDE.md +106 -0
- package/CONTRIBUTING.md +131 -0
- package/README.md +140 -0
- package/biome.json +34 -0
- package/bun.lock +252 -0
- package/dist/cli.d.ts +5 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +21 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/auth.d.ts +3 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/auth.js +140 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/channel.d.ts +3 -0
- package/dist/commands/channel.d.ts.map +1 -0
- package/dist/commands/channel.js +118 -0
- package/dist/commands/channel.js.map +1 -0
- package/dist/commands/file.d.ts +3 -0
- package/dist/commands/file.d.ts.map +1 -0
- package/dist/commands/file.js +113 -0
- package/dist/commands/file.js.map +1 -0
- package/dist/commands/index.d.ts +9 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +9 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/message.d.ts +3 -0
- package/dist/commands/message.d.ts.map +1 -0
- package/dist/commands/message.js +214 -0
- package/dist/commands/message.js.map +1 -0
- package/dist/commands/reaction.d.ts +3 -0
- package/dist/commands/reaction.d.ts.map +1 -0
- package/dist/commands/reaction.js +100 -0
- package/dist/commands/reaction.js.map +1 -0
- package/dist/commands/snapshot.d.ts +3 -0
- package/dist/commands/snapshot.d.ts.map +1 -0
- package/dist/commands/snapshot.js +88 -0
- package/dist/commands/snapshot.js.map +1 -0
- package/dist/commands/user.d.ts +3 -0
- package/dist/commands/user.d.ts.map +1 -0
- package/dist/commands/user.js +96 -0
- package/dist/commands/user.js.map +1 -0
- package/dist/commands/workspace.d.ts +3 -0
- package/dist/commands/workspace.d.ts.map +1 -0
- package/dist/commands/workspace.js +89 -0
- package/dist/commands/workspace.js.map +1 -0
- package/dist/lib/credential-manager.d.ts +13 -0
- package/dist/lib/credential-manager.d.ts.map +1 -0
- package/dist/lib/credential-manager.js +58 -0
- package/dist/lib/credential-manager.js.map +1 -0
- package/dist/lib/index.d.ts +3 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +3 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/ref-manager.d.ts +26 -0
- package/dist/lib/ref-manager.d.ts.map +1 -0
- package/dist/lib/ref-manager.js +92 -0
- package/dist/lib/ref-manager.js.map +1 -0
- package/dist/lib/slack-client.d.ts +37 -0
- package/dist/lib/slack-client.d.ts.map +1 -0
- package/dist/lib/slack-client.js +379 -0
- package/dist/lib/slack-client.js.map +1 -0
- package/dist/lib/token-extractor.d.ts +28 -0
- package/dist/lib/token-extractor.d.ts.map +1 -0
- package/dist/lib/token-extractor.js +401 -0
- package/dist/lib/token-extractor.js.map +1 -0
- package/dist/package.json +37 -0
- package/dist/src/cli.d.ts +5 -0
- package/dist/src/cli.d.ts.map +1 -0
- package/dist/src/cli.js +22 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/platforms/discord/cli.d.ts +5 -0
- package/dist/src/platforms/discord/cli.d.ts.map +1 -0
- package/dist/src/platforms/discord/cli.js +22 -0
- package/dist/src/platforms/discord/cli.js.map +1 -0
- package/dist/src/platforms/discord/client.d.ts +34 -0
- package/dist/src/platforms/discord/client.d.ts.map +1 -0
- package/dist/src/platforms/discord/client.js +187 -0
- package/dist/src/platforms/discord/client.js.map +1 -0
- package/dist/src/platforms/discord/client.test.d.ts +2 -0
- package/dist/src/platforms/discord/client.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/client.test.js +367 -0
- package/dist/src/platforms/discord/client.test.js.map +1 -0
- package/dist/src/platforms/discord/commands/auth.d.ts +13 -0
- package/dist/src/platforms/discord/commands/auth.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/auth.js +155 -0
- package/dist/src/platforms/discord/commands/auth.js.map +1 -0
- package/dist/src/platforms/discord/commands/auth.test.d.ts +2 -0
- package/dist/src/platforms/discord/commands/auth.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/auth.test.js +65 -0
- package/dist/src/platforms/discord/commands/auth.test.js.map +1 -0
- package/dist/src/platforms/discord/commands/channel.d.ts +13 -0
- package/dist/src/platforms/discord/commands/channel.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/channel.js +99 -0
- package/dist/src/platforms/discord/commands/channel.js.map +1 -0
- package/dist/src/platforms/discord/commands/channel.test.d.ts +2 -0
- package/dist/src/platforms/discord/commands/channel.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/channel.test.js +136 -0
- package/dist/src/platforms/discord/commands/channel.test.js.map +1 -0
- package/dist/src/platforms/discord/commands/file.d.ts +13 -0
- package/dist/src/platforms/discord/commands/file.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/file.js +99 -0
- package/dist/src/platforms/discord/commands/file.js.map +1 -0
- package/dist/src/platforms/discord/commands/file.test.d.ts +2 -0
- package/dist/src/platforms/discord/commands/file.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/file.test.js +83 -0
- package/dist/src/platforms/discord/commands/file.test.js.map +1 -0
- package/dist/src/platforms/discord/commands/guild.d.ts +15 -0
- package/dist/src/platforms/discord/commands/guild.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/guild.js +102 -0
- package/dist/src/platforms/discord/commands/guild.js.map +1 -0
- package/dist/src/platforms/discord/commands/guild.test.d.ts +2 -0
- package/dist/src/platforms/discord/commands/guild.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/guild.test.js +100 -0
- package/dist/src/platforms/discord/commands/guild.test.js.map +1 -0
- package/dist/src/platforms/discord/commands/index.d.ts +9 -0
- package/dist/src/platforms/discord/commands/index.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/index.js +9 -0
- package/dist/src/platforms/discord/commands/index.js.map +1 -0
- package/dist/src/platforms/discord/commands/message.d.ts +17 -0
- package/dist/src/platforms/discord/commands/message.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/message.js +131 -0
- package/dist/src/platforms/discord/commands/message.js.map +1 -0
- package/dist/src/platforms/discord/commands/message.test.d.ts +2 -0
- package/dist/src/platforms/discord/commands/message.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/message.test.js +91 -0
- package/dist/src/platforms/discord/commands/message.test.js.map +1 -0
- package/dist/src/platforms/discord/commands/reaction.d.ts +12 -0
- package/dist/src/platforms/discord/commands/reaction.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/reaction.js +99 -0
- package/dist/src/platforms/discord/commands/reaction.js.map +1 -0
- package/dist/src/platforms/discord/commands/reaction.test.d.ts +2 -0
- package/dist/src/platforms/discord/commands/reaction.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/reaction.test.js +115 -0
- package/dist/src/platforms/discord/commands/reaction.test.js.map +1 -0
- package/dist/src/platforms/discord/commands/snapshot.d.ts +9 -0
- package/dist/src/platforms/discord/commands/snapshot.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/snapshot.js +80 -0
- package/dist/src/platforms/discord/commands/snapshot.js.map +1 -0
- package/dist/src/platforms/discord/commands/snapshot.test.d.ts +2 -0
- package/dist/src/platforms/discord/commands/snapshot.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/snapshot.test.js +25 -0
- package/dist/src/platforms/discord/commands/snapshot.test.js.map +1 -0
- package/dist/src/platforms/discord/commands/user.d.ts +3 -0
- package/dist/src/platforms/discord/commands/user.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/user.js +94 -0
- package/dist/src/platforms/discord/commands/user.js.map +1 -0
- package/dist/src/platforms/discord/commands/user.test.d.ts +2 -0
- package/dist/src/platforms/discord/commands/user.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/user.test.js +103 -0
- package/dist/src/platforms/discord/commands/user.test.js.map +1 -0
- package/dist/src/platforms/discord/credential-manager.d.ts +33 -0
- package/dist/src/platforms/discord/credential-manager.d.ts.map +1 -0
- package/dist/src/platforms/discord/credential-manager.js +73 -0
- package/dist/src/platforms/discord/credential-manager.js.map +1 -0
- package/dist/src/platforms/discord/credential-manager.test.d.ts +2 -0
- package/dist/src/platforms/discord/credential-manager.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/credential-manager.test.js +136 -0
- package/dist/src/platforms/discord/credential-manager.test.js.map +1 -0
- package/dist/src/platforms/discord/token-extractor.d.ts +55 -0
- package/dist/src/platforms/discord/token-extractor.d.ts.map +1 -0
- package/dist/src/platforms/discord/token-extractor.js +462 -0
- package/dist/src/platforms/discord/token-extractor.js.map +1 -0
- package/dist/src/platforms/discord/token-extractor.test.d.ts +2 -0
- package/dist/src/platforms/discord/token-extractor.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/token-extractor.test.js +789 -0
- package/dist/src/platforms/discord/token-extractor.test.js.map +1 -0
- package/dist/src/platforms/discord/types.d.ts +251 -0
- package/dist/src/platforms/discord/types.d.ts.map +1 -0
- package/dist/src/platforms/discord/types.js +74 -0
- package/dist/src/platforms/discord/types.js.map +1 -0
- package/dist/src/platforms/discord/types.test.d.ts +2 -0
- package/dist/src/platforms/discord/types.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/types.test.js +211 -0
- package/dist/src/platforms/discord/types.test.js.map +1 -0
- package/dist/src/platforms/slack/cli.d.ts +5 -0
- package/dist/src/platforms/slack/cli.d.ts.map +1 -0
- package/dist/src/platforms/slack/cli.js +22 -0
- package/dist/src/platforms/slack/cli.js.map +1 -0
- package/dist/src/platforms/slack/client.d.ts +47 -0
- package/dist/src/platforms/slack/client.d.ts.map +1 -0
- package/dist/src/platforms/slack/client.js +412 -0
- package/dist/src/platforms/slack/client.js.map +1 -0
- package/dist/src/platforms/slack/commands/auth.d.ts +3 -0
- package/dist/src/platforms/slack/commands/auth.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/auth.js +156 -0
- package/dist/src/platforms/slack/commands/auth.js.map +1 -0
- package/dist/src/platforms/slack/commands/channel.d.ts +3 -0
- package/dist/src/platforms/slack/commands/channel.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/channel.js +118 -0
- package/dist/src/platforms/slack/commands/channel.js.map +1 -0
- package/dist/src/platforms/slack/commands/file.d.ts +3 -0
- package/dist/src/platforms/slack/commands/file.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/file.js +113 -0
- package/dist/src/platforms/slack/commands/file.js.map +1 -0
- package/dist/src/platforms/slack/commands/index.d.ts +9 -0
- package/dist/src/platforms/slack/commands/index.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/index.js +9 -0
- package/dist/src/platforms/slack/commands/index.js.map +1 -0
- package/dist/src/platforms/slack/commands/message.d.ts +3 -0
- package/dist/src/platforms/slack/commands/message.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/message.js +263 -0
- package/dist/src/platforms/slack/commands/message.js.map +1 -0
- package/dist/src/platforms/slack/commands/reaction.d.ts +3 -0
- package/dist/src/platforms/slack/commands/reaction.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/reaction.js +100 -0
- package/dist/src/platforms/slack/commands/reaction.js.map +1 -0
- package/dist/src/platforms/slack/commands/snapshot.d.ts +3 -0
- package/dist/src/platforms/slack/commands/snapshot.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/snapshot.js +87 -0
- package/dist/src/platforms/slack/commands/snapshot.js.map +1 -0
- package/dist/src/platforms/slack/commands/user.d.ts +3 -0
- package/dist/src/platforms/slack/commands/user.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/user.js +96 -0
- package/dist/src/platforms/slack/commands/user.js.map +1 -0
- package/dist/src/platforms/slack/commands/workspace.d.ts +3 -0
- package/dist/src/platforms/slack/commands/workspace.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/workspace.js +89 -0
- package/dist/src/platforms/slack/commands/workspace.js.map +1 -0
- package/dist/src/platforms/slack/credential-manager.d.ts +13 -0
- package/dist/src/platforms/slack/credential-manager.d.ts.map +1 -0
- package/dist/src/platforms/slack/credential-manager.js +58 -0
- package/dist/src/platforms/slack/credential-manager.js.map +1 -0
- package/dist/src/platforms/slack/index.d.ts +3 -0
- package/dist/src/platforms/slack/index.d.ts.map +1 -0
- package/dist/src/platforms/slack/index.js +3 -0
- package/dist/src/platforms/slack/index.js.map +1 -0
- package/dist/src/platforms/slack/token-extractor.d.ts +28 -0
- package/dist/src/platforms/slack/token-extractor.d.ts.map +1 -0
- package/dist/src/platforms/slack/token-extractor.js +401 -0
- package/dist/src/platforms/slack/token-extractor.js.map +1 -0
- package/dist/src/platforms/slack/types.d.ts +369 -0
- package/dist/src/platforms/slack/types.d.ts.map +1 -0
- package/dist/src/platforms/slack/types.js +92 -0
- package/dist/src/platforms/slack/types.js.map +1 -0
- package/dist/src/shared/utils/concurrency.d.ts +2 -0
- package/dist/src/shared/utils/concurrency.d.ts.map +1 -0
- package/dist/src/shared/utils/concurrency.js +14 -0
- package/dist/src/shared/utils/concurrency.js.map +1 -0
- package/dist/src/shared/utils/concurrency.test.d.ts +2 -0
- package/dist/src/shared/utils/concurrency.test.d.ts.map +1 -0
- package/dist/src/shared/utils/concurrency.test.js +39 -0
- package/dist/src/shared/utils/concurrency.test.js.map +1 -0
- package/dist/src/shared/utils/error-handler.d.ts +2 -0
- package/dist/src/shared/utils/error-handler.d.ts.map +1 -0
- package/dist/src/shared/utils/error-handler.js +5 -0
- package/dist/src/shared/utils/error-handler.js.map +1 -0
- package/dist/src/shared/utils/output.d.ts +2 -0
- package/dist/src/shared/utils/output.d.ts.map +1 -0
- package/dist/src/shared/utils/output.js +4 -0
- package/dist/src/shared/utils/output.js.map +1 -0
- package/dist/tests/cli.test.d.ts +2 -0
- package/dist/tests/cli.test.d.ts.map +1 -0
- package/dist/tests/cli.test.js +83 -0
- package/dist/tests/cli.test.js.map +1 -0
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/CURRENT +1 -0
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/LOCK +0 -0
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/LOG +3 -0
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/LOG.old +1 -0
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/MANIFEST-000004 +0 -0
- package/dist/tests/commands/auth.test.d.ts +2 -0
- package/dist/tests/commands/auth.test.d.ts.map +1 -0
- package/dist/tests/commands/auth.test.js +304 -0
- package/dist/tests/commands/auth.test.js.map +1 -0
- package/dist/tests/commands/channel.test.d.ts +2 -0
- package/dist/tests/commands/channel.test.d.ts.map +1 -0
- package/dist/tests/commands/channel.test.js +166 -0
- package/dist/tests/commands/channel.test.js.map +1 -0
- package/dist/tests/commands/file.test.d.ts +2 -0
- package/dist/tests/commands/file.test.d.ts.map +1 -0
- package/dist/tests/commands/file.test.js +175 -0
- package/dist/tests/commands/file.test.js.map +1 -0
- package/dist/tests/commands/message.test.d.ts +2 -0
- package/dist/tests/commands/message.test.d.ts.map +1 -0
- package/dist/tests/commands/message.test.js +293 -0
- package/dist/tests/commands/message.test.js.map +1 -0
- package/dist/tests/commands/reaction.test.d.ts +2 -0
- package/dist/tests/commands/reaction.test.d.ts.map +1 -0
- package/dist/tests/commands/reaction.test.js +84 -0
- package/dist/tests/commands/reaction.test.js.map +1 -0
- package/dist/tests/commands/snapshot.test.d.ts +2 -0
- package/dist/tests/commands/snapshot.test.d.ts.map +1 -0
- package/dist/tests/commands/snapshot.test.js +280 -0
- package/dist/tests/commands/snapshot.test.js.map +1 -0
- package/dist/tests/commands/user.test.d.ts +2 -0
- package/dist/tests/commands/user.test.d.ts.map +1 -0
- package/dist/tests/commands/user.test.js +117 -0
- package/dist/tests/commands/user.test.js.map +1 -0
- package/dist/tests/commands/workspace.test.d.ts +2 -0
- package/dist/tests/commands/workspace.test.d.ts.map +1 -0
- package/dist/tests/commands/workspace.test.js +453 -0
- package/dist/tests/commands/workspace.test.js.map +1 -0
- package/dist/tests/credential-manager.test.d.ts +2 -0
- package/dist/tests/credential-manager.test.d.ts.map +1 -0
- package/dist/tests/credential-manager.test.js +199 -0
- package/dist/tests/credential-manager.test.js.map +1 -0
- package/dist/tests/slack-client.test.d.ts +2 -0
- package/dist/tests/slack-client.test.d.ts.map +1 -0
- package/dist/tests/slack-client.test.js +741 -0
- package/dist/tests/slack-client.test.js.map +1 -0
- package/dist/tests/types.test.d.ts +2 -0
- package/dist/tests/types.test.d.ts.map +1 -0
- package/dist/tests/types.test.js +215 -0
- package/dist/tests/types.test.js.map +1 -0
- package/dist/types/index.d.ts +369 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +92 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/error-handler.d.ts +2 -0
- package/dist/utils/error-handler.d.ts.map +1 -0
- package/dist/utils/error-handler.js +5 -0
- package/dist/utils/error-handler.js.map +1 -0
- package/dist/utils/output.d.ts +2 -0
- package/dist/utils/output.d.ts.map +1 -0
- package/dist/utils/output.js +4 -0
- package/dist/utils/output.js.map +1 -0
- package/docs/discord.md +182 -0
- package/docs/slack.md +160 -0
- package/package.json +37 -0
- package/skills/agent-discord/SKILL.md +273 -0
- package/skills/agent-discord/references/authentication.md +294 -0
- package/skills/agent-discord/references/common-patterns.md +455 -0
- package/skills/agent-discord/templates/guild-summary.sh +167 -0
- package/skills/agent-discord/templates/monitor-channel.sh +180 -0
- package/skills/agent-discord/templates/post-message.sh +173 -0
- package/skills/agent-slack/SKILL.md +268 -0
- package/skills/agent-slack/references/authentication.md +332 -0
- package/skills/agent-slack/references/common-patterns.md +527 -0
- package/skills/agent-slack/templates/monitor-channel.sh +186 -0
- package/skills/agent-slack/templates/post-message.sh +130 -0
- package/skills/agent-slack/templates/workspace-summary.sh +149 -0
- package/src/cli.ts +29 -0
- package/src/platforms/discord/cli.ts +36 -0
- package/src/platforms/discord/client.test.ts +456 -0
- package/src/platforms/discord/client.ts +281 -0
- package/src/platforms/discord/commands/auth.test.ts +72 -0
- package/src/platforms/discord/commands/auth.ts +206 -0
- package/src/platforms/discord/commands/channel.test.ts +153 -0
- package/src/platforms/discord/commands/channel.ts +127 -0
- package/src/platforms/discord/commands/file.test.ts +98 -0
- package/src/platforms/discord/commands/file.ts +134 -0
- package/src/platforms/discord/commands/guild.test.ts +117 -0
- package/src/platforms/discord/commands/guild.ts +129 -0
- package/src/platforms/discord/commands/index.ts +8 -0
- package/src/platforms/discord/commands/message.test.ts +107 -0
- package/src/platforms/discord/commands/message.ts +182 -0
- package/src/platforms/discord/commands/reaction.test.ts +123 -0
- package/src/platforms/discord/commands/reaction.ts +156 -0
- package/src/platforms/discord/commands/snapshot.test.ts +29 -0
- package/src/platforms/discord/commands/snapshot.ts +104 -0
- package/src/platforms/discord/commands/user.test.ts +115 -0
- package/src/platforms/discord/commands/user.ts +124 -0
- package/src/platforms/discord/credential-manager.test.ts +173 -0
- package/src/platforms/discord/credential-manager.ts +95 -0
- package/src/platforms/discord/token-extractor.test.ts +918 -0
- package/src/platforms/discord/token-extractor.ts +549 -0
- package/src/platforms/discord/types.test.ts +245 -0
- package/src/platforms/discord/types.ts +158 -0
- package/src/platforms/slack/cli.ts +36 -0
- package/src/platforms/slack/client.ts +466 -0
- package/src/platforms/slack/commands/auth.ts +211 -0
- package/src/platforms/slack/commands/channel.ts +158 -0
- package/src/platforms/slack/commands/file.ts +153 -0
- package/src/platforms/slack/commands/index.ts +8 -0
- package/src/platforms/slack/commands/message.ts +369 -0
- package/src/platforms/slack/commands/reaction.ts +166 -0
- package/src/platforms/slack/commands/snapshot.ts +114 -0
- package/src/platforms/slack/commands/user.ts +110 -0
- package/src/platforms/slack/commands/workspace.ts +111 -0
- package/src/platforms/slack/credential-manager.ts +74 -0
- package/src/platforms/slack/index.ts +2 -0
- package/src/platforms/slack/token-extractor.ts +496 -0
- package/src/platforms/slack/types.ts +193 -0
- package/src/shared/utils/concurrency.test.ts +53 -0
- package/src/shared/utils/concurrency.ts +20 -0
- package/src/shared/utils/error-handler.ts +4 -0
- package/src/shared/utils/output.ts +3 -0
- package/tests/cli.test.ts +94 -0
- package/tests/commands/auth.test.ts +383 -0
- package/tests/commands/channel.test.ts +185 -0
- package/tests/commands/file.test.ts +204 -0
- package/tests/commands/message.test.ts +344 -0
- package/tests/commands/reaction.test.ts +101 -0
- package/tests/commands/snapshot.test.ts +308 -0
- package/tests/commands/user.test.ts +138 -0
- package/tests/commands/workspace.test.ts +528 -0
- package/tests/credential-manager.test.ts +241 -0
- package/tests/slack-client.test.ts +916 -0
- package/tests/types.test.ts +241 -0
- package/tsconfig.json +36 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { expect, mock, test } from 'bun:test'
|
|
2
|
+
|
|
3
|
+
// Mock DiscordClient
|
|
4
|
+
const mockClient = {
|
|
5
|
+
testAuth: mock(async () => ({
|
|
6
|
+
id: 'user123',
|
|
7
|
+
username: 'testuser',
|
|
8
|
+
global_name: 'Test User',
|
|
9
|
+
avatar: 'avatar_hash',
|
|
10
|
+
bot: false,
|
|
11
|
+
})),
|
|
12
|
+
getUser: mock(async (userId: string) => ({
|
|
13
|
+
id: userId,
|
|
14
|
+
username: 'testuser',
|
|
15
|
+
global_name: 'Test User',
|
|
16
|
+
avatar: 'avatar_hash',
|
|
17
|
+
bot: false,
|
|
18
|
+
})),
|
|
19
|
+
listUsers: mock(async (_guildId: string) => [
|
|
20
|
+
{
|
|
21
|
+
id: 'user1',
|
|
22
|
+
username: 'alice',
|
|
23
|
+
global_name: 'Alice',
|
|
24
|
+
avatar: 'avatar1',
|
|
25
|
+
bot: false,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: 'user2',
|
|
29
|
+
username: 'bot_user',
|
|
30
|
+
global_name: 'Bot User',
|
|
31
|
+
avatar: 'avatar2',
|
|
32
|
+
bot: true,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: 'user3',
|
|
36
|
+
username: 'bob',
|
|
37
|
+
global_name: 'Bob',
|
|
38
|
+
avatar: 'avatar3',
|
|
39
|
+
bot: false,
|
|
40
|
+
},
|
|
41
|
+
]),
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
test('me returns current user info', async () => {
|
|
45
|
+
// given: authenticated user
|
|
46
|
+
const user = await mockClient.testAuth()
|
|
47
|
+
|
|
48
|
+
// when: getting current user
|
|
49
|
+
const result = {
|
|
50
|
+
id: user.id,
|
|
51
|
+
username: user.username,
|
|
52
|
+
global_name: user.global_name,
|
|
53
|
+
avatar: user.avatar,
|
|
54
|
+
bot: user.bot,
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// then: returns user object
|
|
58
|
+
expect(result.id).toBe('user123')
|
|
59
|
+
expect(result.username).toBe('testuser')
|
|
60
|
+
expect(result.global_name).toBe('Test User')
|
|
61
|
+
expect(result.bot).toBe(false)
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
test('info returns user details by id', async () => {
|
|
65
|
+
// given: user id
|
|
66
|
+
const userId = 'user123'
|
|
67
|
+
|
|
68
|
+
// when: getting user info
|
|
69
|
+
const user = await mockClient.getUser(userId)
|
|
70
|
+
const result = {
|
|
71
|
+
id: user.id,
|
|
72
|
+
username: user.username,
|
|
73
|
+
global_name: user.global_name,
|
|
74
|
+
avatar: user.avatar,
|
|
75
|
+
bot: user.bot,
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// then: returns user object
|
|
79
|
+
expect(result.id).toBe('user123')
|
|
80
|
+
expect(result.username).toBe('testuser')
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
test('list returns guild members', async () => {
|
|
84
|
+
// given: guild id
|
|
85
|
+
const guildId = 'guild123'
|
|
86
|
+
|
|
87
|
+
// when: listing users
|
|
88
|
+
const users = await mockClient.listUsers(guildId)
|
|
89
|
+
const result = users.map((u) => ({
|
|
90
|
+
id: u.id,
|
|
91
|
+
username: u.username,
|
|
92
|
+
global_name: u.global_name,
|
|
93
|
+
avatar: u.avatar,
|
|
94
|
+
bot: u.bot,
|
|
95
|
+
}))
|
|
96
|
+
|
|
97
|
+
// then: returns array of users
|
|
98
|
+
expect(result).toHaveLength(3)
|
|
99
|
+
expect(result[0].username).toBe('alice')
|
|
100
|
+
expect(result[1].bot).toBe(true)
|
|
101
|
+
expect(result[2].username).toBe('bob')
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
test('list filters out bots when flag not set', async () => {
|
|
105
|
+
// given: guild id and users with bots
|
|
106
|
+
const guildId = 'guild123'
|
|
107
|
+
const users = await mockClient.listUsers(guildId)
|
|
108
|
+
|
|
109
|
+
// when: filtering out bots
|
|
110
|
+
const filtered = users.filter((u) => !u.bot)
|
|
111
|
+
|
|
112
|
+
// then: returns only non-bot users
|
|
113
|
+
expect(filtered).toHaveLength(2)
|
|
114
|
+
expect(filtered.every((u) => !u.bot)).toBe(true)
|
|
115
|
+
})
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { Command } from 'commander'
|
|
2
|
+
import { handleError } from '../../../shared/utils/error-handler'
|
|
3
|
+
import { formatOutput } from '../../../shared/utils/output'
|
|
4
|
+
import { DiscordClient } from '../client'
|
|
5
|
+
import { DiscordCredentialManager } from '../credential-manager'
|
|
6
|
+
|
|
7
|
+
async function listAction(options: { pretty?: boolean }): Promise<void> {
|
|
8
|
+
try {
|
|
9
|
+
const credManager = new DiscordCredentialManager()
|
|
10
|
+
const config = await credManager.load()
|
|
11
|
+
|
|
12
|
+
if (!config.token) {
|
|
13
|
+
console.log(
|
|
14
|
+
formatOutput({ error: 'Not authenticated. Run "auth extract" first.' }, options.pretty)
|
|
15
|
+
)
|
|
16
|
+
process.exit(1)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (!config.current_guild) {
|
|
20
|
+
console.log(
|
|
21
|
+
formatOutput(
|
|
22
|
+
{ error: 'No current guild set. Run "guild switch <id>" first.' },
|
|
23
|
+
options.pretty
|
|
24
|
+
)
|
|
25
|
+
)
|
|
26
|
+
process.exit(1)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const client = new DiscordClient(config.token)
|
|
30
|
+
const users = await client.listUsers(config.current_guild)
|
|
31
|
+
|
|
32
|
+
const output = users.map((user) => ({
|
|
33
|
+
id: user.id,
|
|
34
|
+
username: user.username,
|
|
35
|
+
global_name: user.global_name,
|
|
36
|
+
avatar: user.avatar,
|
|
37
|
+
bot: user.bot,
|
|
38
|
+
}))
|
|
39
|
+
|
|
40
|
+
console.log(formatOutput(output, options.pretty))
|
|
41
|
+
} catch (error) {
|
|
42
|
+
handleError(error as Error)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function infoAction(userId: string, options: { pretty?: boolean }): Promise<void> {
|
|
47
|
+
try {
|
|
48
|
+
const credManager = new DiscordCredentialManager()
|
|
49
|
+
const config = await credManager.load()
|
|
50
|
+
|
|
51
|
+
if (!config.token) {
|
|
52
|
+
console.log(
|
|
53
|
+
formatOutput({ error: 'Not authenticated. Run "auth extract" first.' }, options.pretty)
|
|
54
|
+
)
|
|
55
|
+
process.exit(1)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const client = new DiscordClient(config.token)
|
|
59
|
+
const user = await client.getUser(userId)
|
|
60
|
+
|
|
61
|
+
const output = {
|
|
62
|
+
id: user.id,
|
|
63
|
+
username: user.username,
|
|
64
|
+
global_name: user.global_name,
|
|
65
|
+
avatar: user.avatar,
|
|
66
|
+
bot: user.bot,
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
console.log(formatOutput(output, options.pretty))
|
|
70
|
+
} catch (error) {
|
|
71
|
+
handleError(error as Error)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async function meAction(options: { pretty?: boolean }): Promise<void> {
|
|
76
|
+
try {
|
|
77
|
+
const credManager = new DiscordCredentialManager()
|
|
78
|
+
const config = await credManager.load()
|
|
79
|
+
|
|
80
|
+
if (!config.token) {
|
|
81
|
+
console.log(
|
|
82
|
+
formatOutput({ error: 'Not authenticated. Run "auth extract" first.' }, options.pretty)
|
|
83
|
+
)
|
|
84
|
+
process.exit(1)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const client = new DiscordClient(config.token)
|
|
88
|
+
const user = await client.testAuth()
|
|
89
|
+
|
|
90
|
+
const output = {
|
|
91
|
+
id: user.id,
|
|
92
|
+
username: user.username,
|
|
93
|
+
global_name: user.global_name,
|
|
94
|
+
avatar: user.avatar,
|
|
95
|
+
bot: user.bot,
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
console.log(formatOutput(output, options.pretty))
|
|
99
|
+
} catch (error) {
|
|
100
|
+
handleError(error as Error)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export const userCommand = new Command('user')
|
|
105
|
+
.description('User commands')
|
|
106
|
+
.addCommand(
|
|
107
|
+
new Command('list')
|
|
108
|
+
.description('List guild members')
|
|
109
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
110
|
+
.action(listAction)
|
|
111
|
+
)
|
|
112
|
+
.addCommand(
|
|
113
|
+
new Command('info')
|
|
114
|
+
.description('Get user info')
|
|
115
|
+
.argument('<user-id>', 'User ID')
|
|
116
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
117
|
+
.action(infoAction)
|
|
118
|
+
)
|
|
119
|
+
.addCommand(
|
|
120
|
+
new Command('me')
|
|
121
|
+
.description('Show current authenticated user')
|
|
122
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
123
|
+
.action(meAction)
|
|
124
|
+
)
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { afterEach, beforeEach, expect, test } from 'bun:test'
|
|
2
|
+
import { existsSync } from 'node:fs'
|
|
3
|
+
import { rm } from 'node:fs/promises'
|
|
4
|
+
import { join } from 'node:path'
|
|
5
|
+
import { DiscordCredentialManager } from './credential-manager'
|
|
6
|
+
|
|
7
|
+
const TEST_CONFIG_DIR = '/tmp/discord-test-config'
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
if (existsSync(TEST_CONFIG_DIR)) {
|
|
11
|
+
await rm(TEST_CONFIG_DIR, { recursive: true })
|
|
12
|
+
}
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
afterEach(async () => {
|
|
16
|
+
if (existsSync(TEST_CONFIG_DIR)) {
|
|
17
|
+
await rm(TEST_CONFIG_DIR, { recursive: true })
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
test('load returns default config when file does not exist', async () => {
|
|
22
|
+
const manager = new DiscordCredentialManager(TEST_CONFIG_DIR)
|
|
23
|
+
const config = await manager.load()
|
|
24
|
+
|
|
25
|
+
expect(config).toEqual({
|
|
26
|
+
token: null,
|
|
27
|
+
current_guild: null,
|
|
28
|
+
guilds: {},
|
|
29
|
+
})
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
test('save creates config file with correct permissions', async () => {
|
|
33
|
+
const manager = new DiscordCredentialManager(TEST_CONFIG_DIR)
|
|
34
|
+
const config = {
|
|
35
|
+
token: 'test-token',
|
|
36
|
+
current_guild: 'guild-123',
|
|
37
|
+
guilds: {
|
|
38
|
+
'guild-123': { guild_id: 'guild-123', guild_name: 'Test Guild' },
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
await manager.save(config)
|
|
43
|
+
|
|
44
|
+
const credentialsPath = join(TEST_CONFIG_DIR, 'discord-credentials.json')
|
|
45
|
+
expect(existsSync(credentialsPath)).toBe(true)
|
|
46
|
+
|
|
47
|
+
const file = Bun.file(credentialsPath)
|
|
48
|
+
const content = await file.text()
|
|
49
|
+
const loaded = JSON.parse(content)
|
|
50
|
+
expect(loaded).toEqual(config)
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
test('getToken returns null when not authenticated', async () => {
|
|
54
|
+
const manager = new DiscordCredentialManager(TEST_CONFIG_DIR)
|
|
55
|
+
const token = await manager.getToken()
|
|
56
|
+
|
|
57
|
+
expect(token).toBeNull()
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
test('setToken saves token to config', async () => {
|
|
61
|
+
const manager = new DiscordCredentialManager(TEST_CONFIG_DIR)
|
|
62
|
+
await manager.setToken('test-token-123')
|
|
63
|
+
|
|
64
|
+
const token = await manager.getToken()
|
|
65
|
+
expect(token).toBe('test-token-123')
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
test('getToken returns previously set token', async () => {
|
|
69
|
+
const manager = new DiscordCredentialManager(TEST_CONFIG_DIR)
|
|
70
|
+
await manager.setToken('my-token')
|
|
71
|
+
|
|
72
|
+
const token = await manager.getToken()
|
|
73
|
+
expect(token).toBe('my-token')
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
test('clearToken removes token from config', async () => {
|
|
77
|
+
const manager = new DiscordCredentialManager(TEST_CONFIG_DIR)
|
|
78
|
+
await manager.setToken('test-token')
|
|
79
|
+
await manager.clearToken()
|
|
80
|
+
|
|
81
|
+
const token = await manager.getToken()
|
|
82
|
+
expect(token).toBeNull()
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
test('getCurrentGuild returns null when not set', async () => {
|
|
86
|
+
const manager = new DiscordCredentialManager(TEST_CONFIG_DIR)
|
|
87
|
+
const guild = await manager.getCurrentGuild()
|
|
88
|
+
|
|
89
|
+
expect(guild).toBeNull()
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
test('setCurrentGuild saves guild id', async () => {
|
|
93
|
+
const manager = new DiscordCredentialManager(TEST_CONFIG_DIR)
|
|
94
|
+
await manager.setCurrentGuild('guild-456')
|
|
95
|
+
|
|
96
|
+
const guild = await manager.getCurrentGuild()
|
|
97
|
+
expect(guild).toBe('guild-456')
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
test('getGuilds returns empty object when no guilds set', async () => {
|
|
101
|
+
const manager = new DiscordCredentialManager(TEST_CONFIG_DIR)
|
|
102
|
+
const guilds = await manager.getGuilds()
|
|
103
|
+
|
|
104
|
+
expect(guilds).toEqual({})
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
test('setGuilds saves guilds to config', async () => {
|
|
108
|
+
const manager = new DiscordCredentialManager(TEST_CONFIG_DIR)
|
|
109
|
+
const guilds = {
|
|
110
|
+
'guild-1': { guild_id: 'guild-1', guild_name: 'Guild One' },
|
|
111
|
+
'guild-2': { guild_id: 'guild-2', guild_name: 'Guild Two' },
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
await manager.setGuilds(guilds)
|
|
115
|
+
|
|
116
|
+
const loaded = await manager.getGuilds()
|
|
117
|
+
expect(loaded).toEqual(guilds)
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
test('getCredentials returns null when not authenticated', async () => {
|
|
121
|
+
const manager = new DiscordCredentialManager(TEST_CONFIG_DIR)
|
|
122
|
+
const creds = await manager.getCredentials()
|
|
123
|
+
|
|
124
|
+
expect(creds).toBeNull()
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
test('getCredentials returns null when token exists but no guild selected', async () => {
|
|
128
|
+
const manager = new DiscordCredentialManager(TEST_CONFIG_DIR)
|
|
129
|
+
await manager.setToken('test-token')
|
|
130
|
+
|
|
131
|
+
const creds = await manager.getCredentials()
|
|
132
|
+
expect(creds).toBeNull()
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
test('getCredentials returns null when guild selected but no token', async () => {
|
|
136
|
+
const manager = new DiscordCredentialManager(TEST_CONFIG_DIR)
|
|
137
|
+
await manager.setCurrentGuild('guild-123')
|
|
138
|
+
|
|
139
|
+
const creds = await manager.getCredentials()
|
|
140
|
+
expect(creds).toBeNull()
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
test('getCredentials returns token and guildId when both are set', async () => {
|
|
144
|
+
const manager = new DiscordCredentialManager(TEST_CONFIG_DIR)
|
|
145
|
+
await manager.setToken('test-token-xyz')
|
|
146
|
+
await manager.setCurrentGuild('guild-789')
|
|
147
|
+
|
|
148
|
+
const creds = await manager.getCredentials()
|
|
149
|
+
expect(creds).toEqual({
|
|
150
|
+
token: 'test-token-xyz',
|
|
151
|
+
guildId: 'guild-789',
|
|
152
|
+
})
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
test('multiple operations preserve existing data', async () => {
|
|
156
|
+
const manager = new DiscordCredentialManager(TEST_CONFIG_DIR)
|
|
157
|
+
|
|
158
|
+
// Set initial data
|
|
159
|
+
await manager.setToken('token-1')
|
|
160
|
+
await manager.setCurrentGuild('guild-1')
|
|
161
|
+
const guilds = {
|
|
162
|
+
'guild-1': { guild_id: 'guild-1', guild_name: 'Guild One' },
|
|
163
|
+
}
|
|
164
|
+
await manager.setGuilds(guilds)
|
|
165
|
+
|
|
166
|
+
// Update token
|
|
167
|
+
await manager.setToken('token-2')
|
|
168
|
+
|
|
169
|
+
// Verify all data is preserved
|
|
170
|
+
expect(await manager.getToken()).toBe('token-2')
|
|
171
|
+
expect(await manager.getCurrentGuild()).toBe('guild-1')
|
|
172
|
+
expect(await manager.getGuilds()).toEqual(guilds)
|
|
173
|
+
})
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs'
|
|
2
|
+
import { mkdir } from 'node:fs/promises'
|
|
3
|
+
import { homedir } from 'node:os'
|
|
4
|
+
import { join } from 'node:path'
|
|
5
|
+
|
|
6
|
+
export interface DiscordConfig {
|
|
7
|
+
token: string | null
|
|
8
|
+
current_guild: string | null
|
|
9
|
+
guilds: Record<string, { guild_id: string; guild_name: string }>
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class DiscordCredentialManager {
|
|
13
|
+
private configDir: string
|
|
14
|
+
private credentialsPath: string
|
|
15
|
+
|
|
16
|
+
constructor(configDir?: string) {
|
|
17
|
+
this.configDir = configDir ?? join(homedir(), '.config', 'agent-messenger')
|
|
18
|
+
this.credentialsPath = join(this.configDir, 'discord-credentials.json')
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async load(): Promise<DiscordConfig> {
|
|
22
|
+
if (!existsSync(this.credentialsPath)) {
|
|
23
|
+
return {
|
|
24
|
+
token: null,
|
|
25
|
+
current_guild: null,
|
|
26
|
+
guilds: {},
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const file = Bun.file(this.credentialsPath)
|
|
31
|
+
const content = await file.text()
|
|
32
|
+
return JSON.parse(content) as DiscordConfig
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async save(config: DiscordConfig): Promise<void> {
|
|
36
|
+
await mkdir(this.configDir, { recursive: true })
|
|
37
|
+
|
|
38
|
+
const file = Bun.file(this.credentialsPath)
|
|
39
|
+
await Bun.write(file, JSON.stringify(config, null, 2))
|
|
40
|
+
|
|
41
|
+
await Bun.spawn(['chmod', '0600', this.credentialsPath]).exited
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async getToken(): Promise<string | null> {
|
|
45
|
+
const config = await this.load()
|
|
46
|
+
return config.token
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async setToken(token: string): Promise<void> {
|
|
50
|
+
const config = await this.load()
|
|
51
|
+
config.token = token
|
|
52
|
+
await this.save(config)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async clearToken(): Promise<void> {
|
|
56
|
+
const config = await this.load()
|
|
57
|
+
config.token = null
|
|
58
|
+
await this.save(config)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async getCurrentGuild(): Promise<string | null> {
|
|
62
|
+
const config = await this.load()
|
|
63
|
+
return config.current_guild
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async setCurrentGuild(guildId: string): Promise<void> {
|
|
67
|
+
const config = await this.load()
|
|
68
|
+
config.current_guild = guildId
|
|
69
|
+
await this.save(config)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async getGuilds(): Promise<Record<string, { guild_id: string; guild_name: string }>> {
|
|
73
|
+
const config = await this.load()
|
|
74
|
+
return config.guilds
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async setGuilds(guilds: Record<string, { guild_id: string; guild_name: string }>): Promise<void> {
|
|
78
|
+
const config = await this.load()
|
|
79
|
+
config.guilds = guilds
|
|
80
|
+
await this.save(config)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async getCredentials(): Promise<{ token: string; guildId: string } | null> {
|
|
84
|
+
const config = await this.load()
|
|
85
|
+
|
|
86
|
+
if (!config.token || !config.current_guild) {
|
|
87
|
+
return null
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
token: config.token,
|
|
92
|
+
guildId: config.current_guild,
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|