agent-messenger 1.6.0 → 1.7.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-plugin/marketplace.json +13 -0
- package/.claude-plugin/plugin.json +2 -1
- package/.env.template +5 -0
- package/README.md +3 -1
- package/dist/package.json +3 -2
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +3 -0
- package/dist/src/cli.js.map +1 -1
- package/dist/src/platforms/discordbot/cli.d.ts +5 -0
- package/dist/src/platforms/discordbot/cli.d.ts.map +1 -0
- package/dist/src/platforms/discordbot/cli.js +24 -0
- package/dist/src/platforms/discordbot/cli.js.map +1 -0
- package/dist/src/platforms/discordbot/client.d.ts +41 -0
- package/dist/src/platforms/discordbot/client.d.ts.map +1 -0
- package/dist/src/platforms/discordbot/client.js +256 -0
- package/dist/src/platforms/discordbot/client.js.map +1 -0
- package/dist/src/platforms/discordbot/commands/auth.d.ts +30 -0
- package/dist/src/platforms/discordbot/commands/auth.d.ts.map +1 -0
- package/dist/src/platforms/discordbot/commands/auth.js +180 -0
- package/dist/src/platforms/discordbot/commands/auth.js.map +1 -0
- package/dist/src/platforms/discordbot/commands/channel.d.ts +21 -0
- package/dist/src/platforms/discordbot/commands/channel.d.ts.map +1 -0
- package/dist/src/platforms/discordbot/commands/channel.js +79 -0
- package/dist/src/platforms/discordbot/commands/channel.js.map +1 -0
- package/dist/src/platforms/discordbot/commands/file.d.ts +24 -0
- package/dist/src/platforms/discordbot/commands/file.d.ts.map +1 -0
- package/dist/src/platforms/discordbot/commands/file.js +78 -0
- package/dist/src/platforms/discordbot/commands/file.js.map +1 -0
- package/dist/src/platforms/discordbot/commands/index.d.ts +10 -0
- package/dist/src/platforms/discordbot/commands/index.d.ts.map +1 -0
- package/dist/src/platforms/discordbot/commands/index.js +10 -0
- package/dist/src/platforms/discordbot/commands/index.js.map +1 -0
- package/dist/src/platforms/discordbot/commands/message.d.ts +38 -0
- package/dist/src/platforms/discordbot/commands/message.d.ts.map +1 -0
- package/dist/src/platforms/discordbot/commands/message.js +191 -0
- package/dist/src/platforms/discordbot/commands/message.js.map +1 -0
- package/dist/src/platforms/discordbot/commands/reaction.d.ts +14 -0
- package/dist/src/platforms/discordbot/commands/reaction.d.ts.map +1 -0
- package/dist/src/platforms/discordbot/commands/reaction.js +65 -0
- package/dist/src/platforms/discordbot/commands/reaction.js.map +1 -0
- package/dist/src/platforms/discordbot/commands/server.d.ts +22 -0
- package/dist/src/platforms/discordbot/commands/server.d.ts.map +1 -0
- package/dist/src/platforms/discordbot/commands/server.js +94 -0
- package/dist/src/platforms/discordbot/commands/server.js.map +1 -0
- package/dist/src/platforms/discordbot/commands/shared.d.ts +11 -0
- package/dist/src/platforms/discordbot/commands/shared.d.ts.map +1 -0
- package/dist/src/platforms/discordbot/commands/shared.js +24 -0
- package/dist/src/platforms/discordbot/commands/shared.js.map +1 -0
- package/dist/src/platforms/discordbot/commands/snapshot.d.ts +31 -0
- package/dist/src/platforms/discordbot/commands/snapshot.d.ts.map +1 -0
- package/dist/src/platforms/discordbot/commands/snapshot.js +79 -0
- package/dist/src/platforms/discordbot/commands/snapshot.js.map +1 -0
- package/dist/src/platforms/discordbot/commands/thread.d.ts +25 -0
- package/dist/src/platforms/discordbot/commands/thread.d.ts.map +1 -0
- package/dist/src/platforms/discordbot/commands/thread.js +70 -0
- package/dist/src/platforms/discordbot/commands/thread.js.map +1 -0
- package/dist/src/platforms/discordbot/commands/user.d.ts +23 -0
- package/dist/src/platforms/discordbot/commands/user.d.ts.map +1 -0
- package/dist/src/platforms/discordbot/commands/user.js +74 -0
- package/dist/src/platforms/discordbot/commands/user.js.map +1 -0
- package/dist/src/platforms/discordbot/credential-manager.d.ts +19 -0
- package/dist/src/platforms/discordbot/credential-manager.d.ts.map +1 -0
- package/dist/src/platforms/discordbot/credential-manager.js +130 -0
- package/dist/src/platforms/discordbot/credential-manager.js.map +1 -0
- package/dist/src/platforms/discordbot/index.d.ts +4 -0
- package/dist/src/platforms/discordbot/index.d.ts.map +1 -0
- package/dist/src/platforms/discordbot/index.js +4 -0
- package/dist/src/platforms/discordbot/index.js.map +1 -0
- package/dist/src/platforms/discordbot/types.d.ts +356 -0
- package/dist/src/platforms/discordbot/types.d.ts.map +1 -0
- package/dist/src/platforms/discordbot/types.js +93 -0
- package/dist/src/platforms/discordbot/types.js.map +1 -0
- package/dist/src/platforms/slack/types.d.ts +4 -4
- package/dist/src/platforms/slackbot/types.d.ts +22 -22
- package/docs/content/docs/index.mdx +3 -2
- package/docs/content/docs/integrations/discordbot.mdx +267 -0
- package/docs/content/docs/integrations/meta.json +1 -1
- package/docs/content/docs/quick-start.mdx +3 -2
- package/e2e/config.ts +32 -0
- package/e2e/discordbot.e2e.test.ts +323 -0
- package/e2e/helpers.ts +15 -15
- package/package.json +3 -2
- package/skills/agent-discordbot/SKILL.md +421 -0
- package/skills/agent-discordbot/references/authentication.md +208 -0
- package/skills/agent-discordbot/references/common-patterns.md +229 -0
- package/skills/agent-discordbot/templates/monitor-channel.sh +104 -0
- package/skills/agent-discordbot/templates/post-message.sh +112 -0
- package/skills/agent-discordbot/templates/server-summary.sh +109 -0
- package/src/cli.ts +4 -0
- package/src/platforms/discordbot/cli.ts +39 -0
- package/src/platforms/discordbot/client.test.ts +501 -0
- package/src/platforms/discordbot/client.ts +341 -0
- package/src/platforms/discordbot/commands/auth.test.ts +311 -0
- package/src/platforms/discordbot/commands/auth.ts +225 -0
- package/src/platforms/discordbot/commands/channel.test.ts +237 -0
- package/src/platforms/discordbot/commands/channel.ts +103 -0
- package/src/platforms/discordbot/commands/file.test.ts +143 -0
- package/src/platforms/discordbot/commands/file.ts +108 -0
- package/src/platforms/discordbot/commands/index.ts +9 -0
- package/src/platforms/discordbot/commands/message.test.ts +313 -0
- package/src/platforms/discordbot/commands/message.ts +248 -0
- package/src/platforms/discordbot/commands/reaction.test.ts +79 -0
- package/src/platforms/discordbot/commands/reaction.ts +88 -0
- package/src/platforms/discordbot/commands/server.test.ts +249 -0
- package/src/platforms/discordbot/commands/server.ts +126 -0
- package/src/platforms/discordbot/commands/shared.ts +36 -0
- package/src/platforms/discordbot/commands/snapshot.test.ts +209 -0
- package/src/platforms/discordbot/commands/snapshot.ts +115 -0
- package/src/platforms/discordbot/commands/thread.test.ts +164 -0
- package/src/platforms/discordbot/commands/thread.ts +101 -0
- package/src/platforms/discordbot/commands/user.test.ts +205 -0
- package/src/platforms/discordbot/commands/user.ts +98 -0
- package/src/platforms/discordbot/credential-manager.test.ts +309 -0
- package/src/platforms/discordbot/credential-manager.ts +161 -0
- package/src/platforms/discordbot/index.ts +23 -0
- package/src/platforms/discordbot/types.test.ts +294 -0
- package/src/platforms/discordbot/types.ts +189 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { formatOutput } from '../../../shared/utils/output.js';
|
|
3
|
+
import { DiscordBotClient } from '../client.js';
|
|
4
|
+
import { DiscordBotCredentialManager } from '../credential-manager.js';
|
|
5
|
+
export async function setAction(token, options) {
|
|
6
|
+
try {
|
|
7
|
+
const client = new DiscordBotClient(token);
|
|
8
|
+
const authInfo = await client.testAuth();
|
|
9
|
+
if (!authInfo.bot) {
|
|
10
|
+
return { error: 'Token is not a bot token. Use agent-discord for user tokens.' };
|
|
11
|
+
}
|
|
12
|
+
const botId = options.bot || authInfo.id || 'default';
|
|
13
|
+
const botName = authInfo.username || botId;
|
|
14
|
+
const guilds = await client.listGuilds();
|
|
15
|
+
const firstGuild = guilds[0];
|
|
16
|
+
const credManager = options._credManager ?? new DiscordBotCredentialManager();
|
|
17
|
+
await credManager.setCredentials({
|
|
18
|
+
token,
|
|
19
|
+
bot_id: botId,
|
|
20
|
+
bot_name: botName,
|
|
21
|
+
server_id: firstGuild?.id,
|
|
22
|
+
server_name: firstGuild?.name,
|
|
23
|
+
});
|
|
24
|
+
return {
|
|
25
|
+
success: true,
|
|
26
|
+
bot_id: botId,
|
|
27
|
+
bot_name: botName,
|
|
28
|
+
server_id: firstGuild?.id,
|
|
29
|
+
server_name: firstGuild?.name,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
return { error: error.message };
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export async function clearAction(options) {
|
|
37
|
+
try {
|
|
38
|
+
const credManager = options._credManager ?? new DiscordBotCredentialManager();
|
|
39
|
+
await credManager.clearCredentials();
|
|
40
|
+
return { success: true };
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
return { error: error.message };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export async function statusAction(options) {
|
|
47
|
+
try {
|
|
48
|
+
const credManager = options._credManager ?? new DiscordBotCredentialManager();
|
|
49
|
+
const creds = await credManager.getCredentials(options.bot);
|
|
50
|
+
if (!creds) {
|
|
51
|
+
return {
|
|
52
|
+
valid: false,
|
|
53
|
+
error: options.bot
|
|
54
|
+
? `Bot "${options.bot}" not found. Run "auth list" to see available bots.`
|
|
55
|
+
: 'No credentials configured. Run "auth set <token>" first.',
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
let valid = false;
|
|
59
|
+
let authInfo = null;
|
|
60
|
+
try {
|
|
61
|
+
const client = new DiscordBotClient(creds.token);
|
|
62
|
+
authInfo = await client.testAuth();
|
|
63
|
+
valid = authInfo.bot === true;
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
valid = false;
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
valid,
|
|
70
|
+
bot_id: authInfo?.id ?? creds.bot_id,
|
|
71
|
+
bot_name: authInfo?.username ?? creds.bot_name,
|
|
72
|
+
server_id: creds.server_id,
|
|
73
|
+
server_name: creds.server_name,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
return { error: error.message };
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export async function listAction(options) {
|
|
81
|
+
try {
|
|
82
|
+
const credManager = options._credManager ?? new DiscordBotCredentialManager();
|
|
83
|
+
const all = await credManager.listAll();
|
|
84
|
+
return {
|
|
85
|
+
bots: all.map((b) => ({
|
|
86
|
+
bot_id: b.bot_id,
|
|
87
|
+
bot_name: b.bot_name,
|
|
88
|
+
is_current: b.is_current,
|
|
89
|
+
})),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
return { error: error.message };
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
export async function useAction(botId, options) {
|
|
97
|
+
try {
|
|
98
|
+
const credManager = options._credManager ?? new DiscordBotCredentialManager();
|
|
99
|
+
const found = await credManager.setCurrent(botId);
|
|
100
|
+
if (!found) {
|
|
101
|
+
return { error: `Bot "${botId}" not found. Run "auth list" to see available bots.` };
|
|
102
|
+
}
|
|
103
|
+
const creds = await credManager.getCredentials();
|
|
104
|
+
return {
|
|
105
|
+
success: true,
|
|
106
|
+
bot_id: creds?.bot_id,
|
|
107
|
+
bot_name: creds?.bot_name,
|
|
108
|
+
server_id: creds?.server_id,
|
|
109
|
+
server_name: creds?.server_name,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
return { error: error.message };
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
export async function removeAction(botId, options) {
|
|
117
|
+
try {
|
|
118
|
+
const credManager = options._credManager ?? new DiscordBotCredentialManager();
|
|
119
|
+
const removed = await credManager.removeBot(botId);
|
|
120
|
+
if (!removed) {
|
|
121
|
+
return { error: `Bot "${botId}" not found. Run "auth list" to see available bots.` };
|
|
122
|
+
}
|
|
123
|
+
return { success: true };
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
return { error: error.message };
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function cliOutput(result, pretty, exitOnError = true) {
|
|
130
|
+
console.log(formatOutput(result, pretty));
|
|
131
|
+
if (result.error && exitOnError)
|
|
132
|
+
process.exit(1);
|
|
133
|
+
}
|
|
134
|
+
export const authCommand = new Command('auth')
|
|
135
|
+
.description('Bot authentication commands')
|
|
136
|
+
.addCommand(new Command('set')
|
|
137
|
+
.description('Set bot token')
|
|
138
|
+
.argument('<token>', 'Bot token')
|
|
139
|
+
.option('--bot <id>', 'Bot identifier for switching later')
|
|
140
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
141
|
+
.action(async (token, opts) => {
|
|
142
|
+
cliOutput(await setAction(token, opts), opts.pretty);
|
|
143
|
+
}))
|
|
144
|
+
.addCommand(new Command('clear')
|
|
145
|
+
.description('Clear all stored credentials')
|
|
146
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
147
|
+
.action(async (opts) => {
|
|
148
|
+
cliOutput(await clearAction(opts), opts.pretty);
|
|
149
|
+
}))
|
|
150
|
+
.addCommand(new Command('status')
|
|
151
|
+
.description('Show authentication status')
|
|
152
|
+
.option('--bot <id>', 'Check specific bot (default: current)')
|
|
153
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
154
|
+
.action(async (opts) => {
|
|
155
|
+
const result = await statusAction(opts);
|
|
156
|
+
console.log(formatOutput(result, opts.pretty));
|
|
157
|
+
if (!result.valid)
|
|
158
|
+
process.exit(1);
|
|
159
|
+
}))
|
|
160
|
+
.addCommand(new Command('list')
|
|
161
|
+
.description('List all stored bots')
|
|
162
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
163
|
+
.action(async (opts) => {
|
|
164
|
+
cliOutput(await listAction(opts), opts.pretty);
|
|
165
|
+
}))
|
|
166
|
+
.addCommand(new Command('use')
|
|
167
|
+
.description('Switch active bot')
|
|
168
|
+
.argument('<bot>', 'Bot ID')
|
|
169
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
170
|
+
.action(async (botId, opts) => {
|
|
171
|
+
cliOutput(await useAction(botId, opts), opts.pretty);
|
|
172
|
+
}))
|
|
173
|
+
.addCommand(new Command('remove')
|
|
174
|
+
.description('Remove a stored bot')
|
|
175
|
+
.argument('<bot>', 'Bot ID')
|
|
176
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
177
|
+
.action(async (botId, opts) => {
|
|
178
|
+
cliOutput(await removeAction(botId, opts), opts.pretty);
|
|
179
|
+
}));
|
|
180
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../../src/platforms/discordbot/commands/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAA;AAuBnE,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,KAAa,EAAE,OAAsB;IACnE,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAA;QAC1C,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAA;QAExC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;YAClB,OAAO,EAAE,KAAK,EAAE,8DAA8D,EAAE,CAAA;QAClF,CAAC;QAED,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,IAAI,QAAQ,CAAC,EAAE,IAAI,SAAS,CAAA;QACrD,MAAM,OAAO,GAAG,QAAQ,CAAC,QAAQ,IAAI,KAAK,CAAA;QAE1C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,UAAU,EAAE,CAAA;QACxC,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;QAE5B,MAAM,WAAW,GAAG,OAAO,CAAC,YAAY,IAAI,IAAI,2BAA2B,EAAE,CAAA;QAC7E,MAAM,WAAW,CAAC,cAAc,CAAC;YAC/B,KAAK;YACL,MAAM,EAAE,KAAK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;AACzD,CAAC,CAAC,CACL,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import type { BotOption } from './shared.js';
|
|
3
|
+
interface ActionResult {
|
|
4
|
+
success?: boolean;
|
|
5
|
+
error?: string;
|
|
6
|
+
channels?: Array<{
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
type: number;
|
|
10
|
+
}>;
|
|
11
|
+
id?: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
type?: number;
|
|
14
|
+
topic?: string;
|
|
15
|
+
guild_id?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function listAction(options: BotOption): Promise<ActionResult>;
|
|
18
|
+
export declare function infoAction(channel: string, options: BotOption): Promise<ActionResult>;
|
|
19
|
+
export declare const channelCommand: Command;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=channel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/discordbot/commands/channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAInC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAGzC,UAAU,YAAY;IACpB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,KAAK,CAAC;QACf,EAAE,EAAE,MAAM,CAAA;QACV,IAAI,EAAE,MAAM,CAAA;QACZ,IAAI,EAAE,MAAM,CAAA;KACb,CAAC,CAAA;IACF,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC,CAsB1E;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC,CAsB3F;AAED,eAAO,MAAM,cAAc,SAgCxB,CAAA"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { handleError } from '../../../shared/utils/error-handler.js';
|
|
3
|
+
import { formatOutput } from '../../../shared/utils/output.js';
|
|
4
|
+
import { DiscordBotCredentialManager } from '../credential-manager.js';
|
|
5
|
+
import { getClient } from './shared.js';
|
|
6
|
+
export async function listAction(options) {
|
|
7
|
+
try {
|
|
8
|
+
const serverId = options.server || (await (options._credManager ?? new DiscordBotCredentialManager()).getCurrentServer());
|
|
9
|
+
if (!serverId) {
|
|
10
|
+
return { error: 'No server set. Run "server switch <server-id>" first.' };
|
|
11
|
+
}
|
|
12
|
+
const client = await getClient(options);
|
|
13
|
+
const channels = await client.listChannels(serverId);
|
|
14
|
+
const textChannels = channels.filter((c) => c.type === 0);
|
|
15
|
+
return {
|
|
16
|
+
channels: textChannels.map((c) => ({
|
|
17
|
+
id: c.id,
|
|
18
|
+
name: c.name,
|
|
19
|
+
type: c.type,
|
|
20
|
+
})),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
return { error: error.message };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export async function infoAction(channel, options) {
|
|
28
|
+
try {
|
|
29
|
+
const serverId = options.server || (await (options._credManager ?? new DiscordBotCredentialManager()).getCurrentServer());
|
|
30
|
+
if (!serverId) {
|
|
31
|
+
return { error: 'No server set. Run "server switch <server-id>" first.' };
|
|
32
|
+
}
|
|
33
|
+
const client = await getClient(options);
|
|
34
|
+
const channelId = await client.resolveChannel(serverId, channel);
|
|
35
|
+
const channelInfo = await client.getChannel(channelId);
|
|
36
|
+
return {
|
|
37
|
+
id: channelInfo.id,
|
|
38
|
+
name: channelInfo.name,
|
|
39
|
+
type: channelInfo.type,
|
|
40
|
+
topic: channelInfo.topic,
|
|
41
|
+
guild_id: channelInfo.guild_id,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
return { error: error.message };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export const channelCommand = new Command('channel')
|
|
49
|
+
.description('Channel commands')
|
|
50
|
+
.addCommand(new Command('list')
|
|
51
|
+
.description('List text channels in current server')
|
|
52
|
+
.option('--server <id>', 'Use specific server')
|
|
53
|
+
.option('--bot <id>', 'Use specific bot')
|
|
54
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
55
|
+
.action(async (options) => {
|
|
56
|
+
try {
|
|
57
|
+
const result = await listAction(options);
|
|
58
|
+
console.log(formatOutput(result, options.pretty));
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
handleError(error);
|
|
62
|
+
}
|
|
63
|
+
}))
|
|
64
|
+
.addCommand(new Command('info')
|
|
65
|
+
.description('Get channel info')
|
|
66
|
+
.argument('<channel>', 'Channel ID or name')
|
|
67
|
+
.option('--server <id>', 'Use specific server')
|
|
68
|
+
.option('--bot <id>', 'Use specific bot')
|
|
69
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
70
|
+
.action(async (channelArg, options) => {
|
|
71
|
+
try {
|
|
72
|
+
const result = await infoAction(channelArg, options);
|
|
73
|
+
console.log(formatOutput(result, options.pretty));
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
handleError(error);
|
|
77
|
+
}
|
|
78
|
+
}));
|
|
79
|
+
//# sourceMappingURL=channel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel.js","sourceRoot":"","sources":["../../../../../src/platforms/discordbot/commands/channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OA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AG,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;IACnD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,KAAc,CAAC,CAAA;IAC7B,CAAC;AACH,CAAC,CAAC,CACL;KACA,UAAU,CACT,IAAI,OAAO,CAAC,MAAM,CAAC;KAChB,WAAW,CAAC,kBAAkB,CAAC;KAC/B,QAAQ,CAAC,WAAW,EAAE,oBAAoB,CAAC;KAC3C,MAAM,CAAC,eAAe,EAAE,qBAAqB,CAAC;KAC9C,MAAM,CAAC,YAAY,EAAE,kBAAkB,CAAC;KACxC,MAAM,CAAC,UAAU,EAAE,0BAA0B,CAAC;KAC9C,MAAM,CAAC,KAAK,EAAE,UAAkB,EAAE,OAAkB,EAAE,EAAE;IACvD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;QACpD,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;IACnD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,KAAc,CAAC,CAAA;IAC7B,CAAC;AACH,CAAC,CAAC,CACL,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import type { BotOption } from './shared.js';
|
|
3
|
+
interface FileOutput {
|
|
4
|
+
id: string;
|
|
5
|
+
filename: string;
|
|
6
|
+
size: number;
|
|
7
|
+
url: string;
|
|
8
|
+
content_type?: string | null;
|
|
9
|
+
}
|
|
10
|
+
interface UploadActionResult {
|
|
11
|
+
success?: boolean;
|
|
12
|
+
error?: string;
|
|
13
|
+
file?: FileOutput;
|
|
14
|
+
}
|
|
15
|
+
interface ListActionResult {
|
|
16
|
+
success?: boolean;
|
|
17
|
+
error?: string;
|
|
18
|
+
files?: FileOutput[];
|
|
19
|
+
}
|
|
20
|
+
export declare function uploadAction(channel: string, filePath: string, options: BotOption): Promise<UploadActionResult>;
|
|
21
|
+
export declare function listAction(channel: string, options: BotOption): Promise<ListActionResult>;
|
|
22
|
+
export declare const fileCommand: Command;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/discordbot/commands/file.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAInC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAGzC,UAAU,UAAU;IAClB,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC7B;AAED,UAAU,kBAAkB;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,UAAU,CAAA;CAClB;AAED,UAAU,gBAAgB;IACxB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,UAAU,EAAE,CAAA;CACrB;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAqBrH;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAoB/F;AAED,eAAO,MAAM,WAAW,SAkCrB,CAAA"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { handleError } from '../../../shared/utils/error-handler.js';
|
|
4
|
+
import { formatOutput } from '../../../shared/utils/output.js';
|
|
5
|
+
import { getClient, getCurrentServer } from './shared.js';
|
|
6
|
+
export async function uploadAction(channel, filePath, options) {
|
|
7
|
+
try {
|
|
8
|
+
const serverId = await getCurrentServer(options);
|
|
9
|
+
const client = await getClient(options);
|
|
10
|
+
const channelId = await client.resolveChannel(serverId, channel);
|
|
11
|
+
const resolvedPath = resolve(filePath);
|
|
12
|
+
const file = await client.uploadFile(channelId, resolvedPath);
|
|
13
|
+
const output = {
|
|
14
|
+
id: file.id,
|
|
15
|
+
filename: file.filename,
|
|
16
|
+
size: file.size,
|
|
17
|
+
url: file.url,
|
|
18
|
+
content_type: file.content_type || null,
|
|
19
|
+
};
|
|
20
|
+
return { success: true, file: output };
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
return { error: error.message };
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export async function listAction(channel, options) {
|
|
27
|
+
try {
|
|
28
|
+
const serverId = await getCurrentServer(options);
|
|
29
|
+
const client = await getClient(options);
|
|
30
|
+
const channelId = await client.resolveChannel(serverId, channel);
|
|
31
|
+
const files = await client.listFiles(channelId);
|
|
32
|
+
const output = files.map((file) => ({
|
|
33
|
+
id: file.id,
|
|
34
|
+
filename: file.filename,
|
|
35
|
+
size: file.size,
|
|
36
|
+
url: file.url,
|
|
37
|
+
content_type: file.content_type || null,
|
|
38
|
+
}));
|
|
39
|
+
return { success: true, files: output };
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
return { error: error.message };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export const fileCommand = new Command('file')
|
|
46
|
+
.description('File commands')
|
|
47
|
+
.addCommand(new Command('upload')
|
|
48
|
+
.description('Upload file to channel')
|
|
49
|
+
.argument('<channel>', 'Channel ID or name')
|
|
50
|
+
.argument('<file-path>', 'File path')
|
|
51
|
+
.option('--server <id>', 'Use specific server')
|
|
52
|
+
.option('--bot <id>', 'Use specific bot')
|
|
53
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
54
|
+
.action(async (channelArg, filePathArg, options) => {
|
|
55
|
+
try {
|
|
56
|
+
const result = await uploadAction(channelArg, filePathArg, options);
|
|
57
|
+
console.log(formatOutput(result, options.pretty));
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
handleError(error);
|
|
61
|
+
}
|
|
62
|
+
}))
|
|
63
|
+
.addCommand(new Command('list')
|
|
64
|
+
.description('List files in channel')
|
|
65
|
+
.argument('<channel>', 'Channel ID or name')
|
|
66
|
+
.option('--server <id>', 'Use specific server')
|
|
67
|
+
.option('--bot <id>', 'Use specific bot')
|
|
68
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
69
|
+
.action(async (channelArg, options) => {
|
|
70
|
+
try {
|
|
71
|
+
const result = await listAction(channelArg, options);
|
|
72
|
+
console.log(formatOutput(result, options.pretty));
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
handleError(error);
|
|
76
|
+
}
|
|
77
|
+
}));
|
|
78
|
+
//# sourceMappingURL=file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.js","sourceRoot":"","sources":["../../../../../src/platforms/discordbot/commands/file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAGpD,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAsBtD,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAAe,EAAE,QAAgB,EAAE,OAAkB;IACtF,IAAI,CAAC;QACH,MAAM,QAAQ,GAA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AuB,CAAC;KACpC,QAAQ,CAAC,WAAW,EAAE,oBAAoB,CAAC;KAC3C,MAAM,CAAC,eAAe,EAAE,qBAAqB,CAAC;KAC9C,MAAM,CAAC,YAAY,EAAE,kBAAkB,CAAC;KACxC,MAAM,CAAC,UAAU,EAAE,0BAA0B,CAAC;KAC9C,MAAM,CAAC,KAAK,EAAE,UAAkB,EAAE,OAAkB,EAAE,EAAE;IACvD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;QACpD,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;IACnD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,KAAc,CAAC,CAAA;IAC7B,CAAC;AACH,CAAC,CAAC,CACL,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { authCommand } from './auth.js';
|
|
2
|
+
export { channelCommand } from './channel.js';
|
|
3
|
+
export { fileCommand } from './file.js';
|
|
4
|
+
export { messageCommand } from './message.js';
|
|
5
|
+
export { reactionCommand } from './reaction.js';
|
|
6
|
+
export { serverCommand } from './server.js';
|
|
7
|
+
export { snapshotCommand } from './snapshot.js';
|
|
8
|
+
export { threadCommand } from './thread.js';
|
|
9
|
+
export { userCommand } from './user.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/discordbot/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { authCommand } from './auth.js';
|
|
2
|
+
export { channelCommand } from './channel.js';
|
|
3
|
+
export { fileCommand } from './file.js';
|
|
4
|
+
export { messageCommand } from './message.js';
|
|
5
|
+
export { reactionCommand } from './reaction.js';
|
|
6
|
+
export { serverCommand } from './server.js';
|
|
7
|
+
export { snapshotCommand } from './snapshot.js';
|
|
8
|
+
export { threadCommand } from './thread.js';
|
|
9
|
+
export { userCommand } from './user.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/platforms/discordbot/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import type { BotOption } from './shared.js';
|
|
3
|
+
interface MessageResult {
|
|
4
|
+
id?: string;
|
|
5
|
+
channel_id?: string;
|
|
6
|
+
content?: string;
|
|
7
|
+
author?: string;
|
|
8
|
+
timestamp?: string;
|
|
9
|
+
edited_timestamp?: string;
|
|
10
|
+
thread_id?: string | null;
|
|
11
|
+
messages?: Array<{
|
|
12
|
+
id: string;
|
|
13
|
+
channel_id: string;
|
|
14
|
+
content: string;
|
|
15
|
+
author: string;
|
|
16
|
+
timestamp: string;
|
|
17
|
+
thread_id?: string | null;
|
|
18
|
+
}>;
|
|
19
|
+
deleted?: string;
|
|
20
|
+
error?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function sendAction(channel: string, text: string, options: BotOption & {
|
|
23
|
+
thread?: string;
|
|
24
|
+
}): Promise<MessageResult>;
|
|
25
|
+
export declare function listAction(channel: string, options: BotOption & {
|
|
26
|
+
limit?: string;
|
|
27
|
+
}): Promise<MessageResult>;
|
|
28
|
+
export declare function getAction(channel: string, messageId: string, options: BotOption): Promise<MessageResult>;
|
|
29
|
+
export declare function updateAction(channel: string, messageId: string, text: string, options: BotOption): Promise<MessageResult>;
|
|
30
|
+
export declare function deleteAction(channel: string, messageId: string, options: BotOption & {
|
|
31
|
+
force?: boolean;
|
|
32
|
+
}): Promise<MessageResult>;
|
|
33
|
+
export declare function repliesAction(_channel: string, threadId: string, options: BotOption & {
|
|
34
|
+
limit?: string;
|
|
35
|
+
}): Promise<MessageResult>;
|
|
36
|
+
export declare const messageCommand: Command;
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/discordbot/commands/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAGzC,UAAU,aAAa;IACrB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX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