Skip to content

Commit ac44824

Browse files
committed
update avatar file path
1 parent e5dc694 commit ac44824

File tree

3 files changed

+3
-21
lines changed

3 files changed

+3
-21
lines changed

files/lib/system/discord/WebhookHandler.class.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use wcf\data\discord\webhook\DiscordWebhookList;
99
use wcf\system\cache\runtime\DiscordBotRuntimeCache;
1010
use wcf\system\SingletonFactory;
11-
use wcf\util\FileUtil;
1211

1312
final class WebhookHandler extends SingletonFactory
1413
{
@@ -21,12 +20,7 @@ public function saveWebhooks(int $botID, array $channelIDs, string $usageBy)
2120
}
2221
$api = $bot->getDiscordApi();
2322

24-
$avatar = null;
25-
$avatarFile = \sprintf('%simages/discord_webhook/%s.png', WCF_DIR, $botID);
26-
if (\file_exists($avatarFile)) {
27-
$mimeType = FileUtil::getMimeType($avatarFile);
28-
$avatar = 'data:' . $mimeType . ';base64,' . \base64_encode(\file_get_contents($avatarFile));
29-
}
23+
$avatar = $bot->getWebhookAvatarData();
3024

3125
$list = new DiscordWebhookList();
3226
$list->getConditionBuilder()->add('botID = ?', [$bot->botID]);

files/lib/system/discord/type/WebhookChannelMultiSelectDiscordType.class.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use wcf\data\discord\webhook\DiscordWebhookAction;
77
use wcf\data\discord\webhook\DiscordWebhookList;
88
use wcf\system\exception\UserInputException;
9-
use wcf\util\FileUtil;
109

1110
class WebhookChannelMultiSelectDiscordType extends ChannelMultiSelectDiscordType
1211
{
@@ -67,12 +66,7 @@ public function validate($newValue)
6766

6867
if (!isset($webhookChannelIDs[$botID]) || !\in_array($channelID, $webhookChannelIDs[$botID])) {
6968
$discordApi = $discordBots[$botID]->getDiscordApi();
70-
$avatar = null;
71-
$avatarFile = \sprintf('%simages/discord_webhook/%s.png', WCF_DIR, $botID);
72-
if (\file_exists($avatarFile)) {
73-
$mimeType = FileUtil::getMimeType($avatarFile);
74-
$avatar = 'data:' . $mimeType . ';base64,' . \base64_encode(\file_get_contents($avatarFile));
75-
}
69+
$avatar = $discordBots[$botID]->getWebhookAvatarData();
7670
$response = $discordApi->createWebhook($channelID, $discordBots[$botID]->webhookName, $avatar);
7771
if (!$response['error']) {
7872
$action = new DiscordWebhookAction([], 'create', [

files/lib/system/discord/type/WebhookChannelSelectDiscordType.class.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use wcf\data\discord\webhook\DiscordWebhookAction;
77
use wcf\data\discord\webhook\DiscordWebhookList;
88
use wcf\system\exception\UserInputException;
9-
use wcf\util\FileUtil;
109

1110
class WebhookChannelSelectDiscordType extends ChannelSelectDiscordType
1211
{
@@ -63,12 +62,7 @@ public function validate($newValue, ?int $maxChannels = null)
6362

6463
if (!isset($webhookChannelIDs[$botID]) || !\in_array($channelID, $webhookChannelIDs[$botID])) {
6564
$discordApi = $discordBots[$botID]->getDiscordApi();
66-
$avatar = null;
67-
$avatarFile = \sprintf('%simages/discord_webhook/%s.png', WCF_DIR, $botID);
68-
if (\file_exists($avatarFile)) {
69-
$mimeType = FileUtil::getMimeType($avatarFile);
70-
$avatar = 'data:' . $mimeType . ';base64,' . \base64_encode(\file_get_contents($avatarFile));
71-
}
65+
$avatar = $discordBots[$botID]->getWebhookAvatarData();
7266
$response = $discordApi->createWebhook($channelID, $discordBots[$botID]->webhookName, $avatar);
7367
if (!$response['error']) {
7468
$action = new DiscordWebhookAction([], 'create', [

0 commit comments

Comments
 (0)