feat: zchannel

This commit is contained in:
Saahil 2025-04-13 20:22:40 -04:00
parent d00957e524
commit 71ce034f9f
No known key found for this signature in database
GPG key ID: 8A8B64515254CFC6

44
src/commands/zchannel.ts Normal file
View file

@ -0,0 +1,44 @@
import { Command, onlyForMe } from "../modules/BaseCommand";
import { ModifiedApp } from "../modules/slackapp";
export default class ChannelPing implements Command {
name: string;
description: string;
constructor() {
this.name = `/zchannel`;
this.description = `Pings @channel`;
}
run(app: ModifiedApp) {
app.command(this.name, async ({ command, ack, respond }) => {
await ack();
if (!onlyForMe(command.user_id))
return respond(`:x: You cannot use this command.`);
const user = await app.client.users.info({ user: command.user_id });
const displayName =
user?.user?.profile?.display_name || user?.user?.name || "<unknown>";
const avatar =
user?.user?.profile?.image_original || user?.user?.profile?.image_512;
const payload = {
text: command.text,
username: displayName,
icon_url: avatar,
blocks: [
{
type: "section",
text: {
type: "mrkdwn",
text: command.text,
},
},
],
};
const response = await app.client.chat.postMessage({
channel: command.channel_id,
...payload,
});
});
}
}