mirror of
https://github.com/System-End/slack-end.git
synced 2026-04-19 16:28:19 +00:00
feat: zchannel
This commit is contained in:
parent
d00957e524
commit
71ce034f9f
1 changed files with 44 additions and 0 deletions
44
src/commands/zchannel.ts
Normal file
44
src/commands/zchannel.ts
Normal 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,
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue