11import "reflect-metadata" ;
22import { Action , CodeZeroEvent } from "@code0-tech/hercules" ;
33
4+ import { initDiscordClient } from "./client.js" ;
5+
46import {
5- DiscordEmbedAuthorDataType ,
6- DiscordEmbedDataType ,
7- DiscordEmbedFooterDataType ,
7+ DiscordEmbedField ,
8+ DiscordEmbedFooter ,
9+ DiscordEmbedAuthor ,
10+ DiscordEmbed ,
811} from "./data_types/discordEmbed.js" ;
9- import {
10- DiscordWebhookResponseDataType ,
11- } from "./data_types/discordWebhook.js" ;
12+ import { DiscordChannelType , DiscordChannel } from "./data_types/discordChannel.js" ;
13+ import { DiscordAttachment } from "./data_types/discordAttachment.js" ;
14+ import { DiscordCommandInteraction } from "./data_types/discordCommandInteraction.js" ;
15+ import { DiscordMessage } from "./data_types/discordMessage.js" ;
16+ import { DiscordGuild } from "./data_types/discordGuild.js" ;
17+ import { DiscordGuildMember } from "./data_types/discordGuildMember.js" ;
18+ import { DiscordReaction } from "./data_types/discordReaction.js" ;
19+ import { DiscordUser } from "./data_types/discordUser.js" ;
20+ import { DiscordRole } from "./data_types/discordRole.js" ;
1221
13- import { CreateDiscordEmbedAuthorFunction } from "./functions/createDiscordEmbedAuthorFunction.js" ;
14- import { CreateDiscordEmbedFooterFunction } from "./functions/createDiscordEmbedFooterFunction.js" ;
15- import { CreateDiscordEmbedFunction } from "./functions/createDiscordEmbedFunction.js" ;
16- import { CreateDiscordWebhookUrlFunction } from "./functions/createDiscordWebhookUrlFunction.js" ;
17- import { SendDiscordWebhookFunction } from "./functions/sendDiscordWebhookFunction.js" ;
22+ import { DiscordSendMessageFunction } from "./functions/messaging/discordSendMessage.js" ;
23+ import { DiscordSendDirectMessageFunction } from "./functions/messaging/discordSendDirectMessage.js" ;
24+ import { DiscordReplyToMessageFunction } from "./functions/messaging/discordReplyToMessage.js" ;
25+ import { DiscordEditMessageFunction } from "./functions/messaging/discordEditMessage.js" ;
26+ import { DiscordDeleteMessageFunction } from "./functions/messaging/discordDeleteMessage.js" ;
27+ import { DiscordAddReactionFunction } from "./functions/messaging/discordAddReaction.js" ;
28+ import { DiscordAddRoleToMemberFunction } from "./functions/members/discordAddRoleToMember.js" ;
29+ import { DiscordRemoveRoleFromMemberFunction } from "./functions/members/discordRemoveRoleFromMember.js" ;
30+
31+ import { DiscordMessageCreated } from "./events/discordMessageCreated.js" ;
32+ import { DiscordReactionAdded } from "./events/discordReactionAdded.js" ;
33+ import { DiscordMemberJoined } from "./events/discordMemberJoined.js" ;
34+ import { DiscordMemberLeft } from "./events/discordMemberLeft.js" ;
35+ import { DiscordSlashCommandInvoked } from "./events/discordSlashCommandInvoked.js" ;
1836
1937const action = new Action (
20- process . env . ACTION_ID ?? "discord -action" ,
38+ process . env . ACTION_ID ?? "testing -action" ,
2139 process . env . VERSION ?? "1.0.0" ,
2240 process . env . AQUILA_URL ?? "127.0.0.1:8081" ,
2341 "code0-tech" ,
2442 "simple:discord" ,
25- "Discord integration: create webhook URLs, construct rich embeds , and send webhooks ." ,
43+ "Discord bot integration: send and manage messages, reactions, and roles , and react to Discord events ." ,
2644 [ { code : "en-US" , content : "Discord" } ] ,
27- [
28- {
29- identifier : "webhook_url" ,
30- type : "TEXT" ,
31- defaultValue : "" ,
32- name : [ { code : "en-US" , content : "Webhook URL" } ] ,
33- description : [ { code : "en-US" , content : "Default Discord Webhook URL to use as fallback." } ] ,
34- linkedDataTypes : [ "TEXT" ] ,
35- } ,
36- {
37- identifier : "username" ,
38- type : "TEXT" ,
39- defaultValue : "" ,
40- name : [ { code : "en-US" , content : "Username" } ] ,
41- description : [ { code : "en-US" , content : "Default username for the Discord webhook poster." } ] ,
42- linkedDataTypes : [ "TEXT" ] ,
43- } ,
44- {
45- identifier : "avatar_url" ,
46- type : "TEXT" ,
47- defaultValue : "" ,
48- name : [ { code : "en-US" , content : "Avatar URL" } ] ,
49- description : [ { code : "en-US" , content : "Default avatar image URL for the Discord webhook poster." } ] ,
50- linkedDataTypes : [ "TEXT" ] ,
51- } ,
52- ]
45+ [ ]
5346) ;
5447
55- action . registerDataTypeClass ( DiscordEmbedFooterDataType ) ;
56- action . registerDataTypeClass ( DiscordEmbedAuthorDataType ) ;
57- action . registerDataTypeClass ( DiscordEmbedDataType ) ;
58- action . registerDataTypeClass ( DiscordWebhookResponseDataType ) ;
48+ action . registerDataTypeClass ( DiscordEmbedField ) ;
49+ action . registerDataTypeClass ( DiscordEmbedFooter ) ;
50+ action . registerDataTypeClass ( DiscordEmbedAuthor ) ;
51+ action . registerDataTypeClass ( DiscordEmbed ) ;
52+ action . registerDataTypeClass ( DiscordChannelType ) ;
53+ action . registerDataTypeClass ( DiscordChannel ) ;
54+ action . registerDataTypeClass ( DiscordAttachment ) ;
55+ action . registerDataTypeClass ( DiscordCommandInteraction ) ;
56+ action . registerDataTypeClass ( DiscordMessage ) ;
57+ action . registerDataTypeClass ( DiscordGuild ) ;
58+ action . registerDataTypeClass ( DiscordGuildMember ) ;
59+ action . registerDataTypeClass ( DiscordReaction ) ;
60+ action . registerDataTypeClass ( DiscordUser ) ;
61+ action . registerDataTypeClass ( DiscordRole ) ;
62+
63+ action . registerRuntimeFunction ( DiscordSendMessageFunction ) ;
64+ action . registerRuntimeFunction ( DiscordSendDirectMessageFunction ) ;
65+ action . registerRuntimeFunction ( DiscordReplyToMessageFunction ) ;
66+ action . registerRuntimeFunction ( DiscordEditMessageFunction ) ;
67+ action . registerRuntimeFunction ( DiscordDeleteMessageFunction ) ;
68+ action . registerRuntimeFunction ( DiscordAddReactionFunction ) ;
69+ action . registerRuntimeFunction ( DiscordAddRoleToMemberFunction ) ;
70+ action . registerRuntimeFunction ( DiscordRemoveRoleFromMemberFunction ) ;
5971
60- action . registerRuntimeFunction ( CreateDiscordWebhookUrlFunction ) ;
61- action . registerRuntimeFunction ( CreateDiscordEmbedFooterFunction ) ;
62- action . registerRuntimeFunction ( CreateDiscordEmbedAuthorFunction ) ;
63- action . registerRuntimeFunction ( CreateDiscordEmbedFunction ) ;
64- action . registerRuntimeFunction ( SendDiscordWebhookFunction ) ;
72+ action . registerRuntimeEventClass ( DiscordMessageCreated ) ;
73+ action . registerRuntimeEventClass ( DiscordReactionAdded ) ;
74+ action . registerRuntimeEventClass ( DiscordMemberJoined ) ;
75+ action . registerRuntimeEventClass ( DiscordMemberLeft ) ;
76+ action . registerRuntimeEventClass ( DiscordSlashCommandInvoked ) ;
6577
6678action . on ( CodeZeroEvent . connected , ( ) => {
6779 console . log ( "Connected to aquila" ) ;
@@ -81,6 +93,12 @@ action.connect(process.env.AUTH_TOKEN ?? "your_auth_token_here").catch((err: Err
8193 action . emit ( CodeZeroEvent . error , err ) ;
8294} ) ;
8395
96+ initDiscordClient ( process . env . DISCORD_BOT_TOKEN ?? "your_discord_bot_token_here" , ( err ) => {
97+ action . emit ( CodeZeroEvent . error , err ) ;
98+ } ) . catch ( ( err : Error ) => {
99+ action . emit ( CodeZeroEvent . error , err ) ;
100+ } ) ;
101+
84102action . on ( CodeZeroEvent . moduleUpdated , ( message : any ) => {
85103 console . dir ( message , { depth : null } ) ;
86104 console . dir ( action . configs . values ( ) , { depth : null } ) ;
0 commit comments