File tree Expand file tree Collapse file tree 4 files changed +74
-0
lines changed Expand file tree Collapse file tree 4 files changed +74
-0
lines changed Original file line number Diff line number Diff line change 5
5
use wcf \acp \page \DiscordWebhookListPage ;
6
6
use wcf \event \acp \dashboard \box \PHPExtensionCollecting ;
7
7
use wcf \event \acp \menu \item \ItemCollecting ;
8
+ use wcf \event \worker \RebuildWorkerCollecting ;
8
9
use wcf \system \event \EventHandler ;
9
10
use wcf \system \menu \acp \AcpMenuItem ;
10
11
use wcf \system \request \LinkHandler ;
11
12
use wcf \system \style \FontAwesomeIcon ;
12
13
use wcf \system \WCF ;
14
+ use wcf \system \worker \DiscordWebhookAvatarRebuildDataWorker ;
13
15
14
16
return static function (): void {
15
17
EventHandler::getInstance ()->register (ItemCollecting::class, static function (ItemCollecting $ event ) {
@@ -68,4 +70,11 @@ static function (PHPExtensionCollecting $event) {
68
70
$ event ->register ('sodium ' );
69
71
}
70
72
);
73
+
74
+ EventHandler::getInstance ()->register (
75
+ RebuildWorkerCollecting::class,
76
+ static function (RebuildWorkerCollecting $ event ) {
77
+ $ event ->register (DiscordWebhookAvatarRebuildDataWorker::class, 0 );
78
+ }
79
+ );
71
80
};
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace wcf \system \worker ;
4
+
5
+ use Override ;
6
+ use wcf \data \discord \bot \DiscordBotEditor ;
7
+ use wcf \data \discord \bot \DiscordBotList ;
8
+ use wcf \data \file \FileEditor ;
9
+
10
+ final class DiscordWebhookAvatarRebuildDataWorker extends AbstractRebuildDataWorker
11
+ {
12
+ /**
13
+ * @inheritDoc
14
+ */
15
+ protected $ objectListClassName = DiscordBotList::class;
16
+
17
+ #[Override]
18
+ public function execute ()
19
+ {
20
+ parent ::execute ();
21
+
22
+ if (!\count ($ this ->objectList )) {
23
+ return ;
24
+ }
25
+
26
+ foreach ($ this ->objectList as $ bot ) {
27
+ $ avatarFile = \sprintf ('%simages/discord_webhook/%s.png ' , WCF_DIR , $ bot ->botID );
28
+ if (!\file_exists ($ avatarFile )) {
29
+ continue ;
30
+ }
31
+
32
+ $ editor = new DiscordBotEditor ($ bot );
33
+
34
+ $ file = FileEditor::createFromExistingFile (
35
+ $ avatarFile ,
36
+ $ bot ->botID . '.png ' ,
37
+ 'dev.hanashi.wsc.discord.webhook.avatar '
38
+ );
39
+
40
+ if ($ file === null ) {
41
+ continue ;
42
+ }
43
+
44
+ $ editor ->update ([
45
+ 'webhookIconID ' => $ file ->fileID ,
46
+ ]);
47
+ }
48
+ }
49
+
50
+ #[Override]
51
+ protected function initObjectList ()
52
+ {
53
+ parent ::initObjectList ();
54
+
55
+ $ this ->objectList ->getConditionBuilder ()->add ('webhookIconID IS NULL ' );
56
+ }
57
+ }
Original file line number Diff line number Diff line change 117
117
<category name =" wcf.acp.discordBotSelectOptionType" >
118
118
<item name =" wcf.acp.discordBotSelectOptionType.noBot" ><![CDATA[ {if LANGUAGE_USE_INFORMAL_VARIANT}Du hast{else}Sie haben{/if} noch keinen Discord-Bot angelegt. Dies {if LANGUAGE_USE_INFORMAL_VARIANT}kannst du{else}können Sie{/if} unter <a href="{link controller="DiscordBotAddManager"}{/link}">Discord-Bot</a> erledigen.]]> </item >
119
119
</category >
120
+ <category name =" wcf.acp.rebuildData" >
121
+ <item name =" wcf.acp.rebuildData.wcf_system_worker_DiscordWebhookAvatarRebuildDataWorker" ><![CDATA[ Discord-Webhook-Avatar aktualisieren]]> </item >
122
+ <item name =" wcf.acp.rebuildData.wcf_system_worker_DiscordWebhookAvatarRebuildDataWorker.description" ><![CDATA[ Aktualisiert Avatare für Discord-Webhook.]]> </item >
123
+ </category >
120
124
</import >
121
125
<delete >
122
126
<item name =" wcf.acp.discordBotAddManager.useOAuth2.description" />
Original file line number Diff line number Diff line change @@ -117,6 +117,10 @@ Go the <a href="https://discord.com/developers/applications" class="externalURL"
117
117
<category name =" wcf.acp.discordBotSelectOptionType" >
118
118
<item name =" wcf.acp.discordBotSelectOptionType.noBot" ><![CDATA[ You haven't created a discord bot yet. You can do this under <a href="{link controller="DiscordBotAddManager"}{/link}">Discord bot</a>.]]> </item >
119
119
</category >
120
+ <category name =" wcf.acp.rebuildData" >
121
+ <item name =" wcf.acp.rebuildData.wcf_system_worker_DiscordWebhookAvatarRebuildDataWorker" ><![CDATA[ Update discord webhook avatar]]> </item >
122
+ <item name =" wcf.acp.rebuildData.wcf_system_worker_DiscordWebhookAvatarRebuildDataWorker.description" ><![CDATA[ Updates avatars for discord webhook.]]> </item >
123
+ </category >
120
124
</import >
121
125
<delete >
122
126
<item name =" wcf.acp.discordBotAddManager.useOAuth2.description" />
You can’t perform that action at this time.
0 commit comments