Skip to content

Commit

Permalink
Fixt Problem wenn Rolle nicht zurück kommt
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanashi committed Jul 3, 2024
1 parent e9607bf commit a27fa30
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace wcf\system\discord\type;

use Throwable;
use wcf\data\discord\bot\DiscordBotList;
use wcf\system\exception\UserInputException;
use wcf\system\WCF;
Expand Down Expand Up @@ -54,10 +55,17 @@ public function getFormElement($value, $channelTypes = [])
];
}

$realValue = [];
try {
$realValue = \unserialize($value);
} catch (Throwable $e) {
// do nothing
}

WCF::getTPL()->assign([
'bots' => $channels,
'optionName' => $this->optionName,
'value' => \unserialize($value),
'value' => $realValue,
'channelTypes' => $channelTypes,
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace wcf\system\discord\type;

use UnexpectedValueException;
use Throwable;
use wcf\data\discord\bot\DiscordBotList;
use wcf\system\exception\UserInputException;
use wcf\system\WCF;
Expand Down Expand Up @@ -59,7 +59,7 @@ public function getFormElement($value, $channelTypes = [])
$realValue = [];
try {
$realValue = \unserialize($value);
} catch (UnexpectedValueException $e) {
} catch (Throwable $e) {
// do nothing
}

Expand Down
18 changes: 13 additions & 5 deletions files/lib/system/discord/type/RoleMultiSelectDiscordType.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace wcf\system\discord\type;

use Throwable;
use wcf\data\discord\bot\DiscordBotList;
use wcf\system\exception\UserInputException;
use wcf\system\WCF;
Expand All @@ -27,11 +28,11 @@ public function getFormElement($value)
$roles = [];
$guildRoles = $this->getGuildRoles();
foreach ($this->getDiscordBotList() as $discordBot) {
$rolesTmp = [];
if (isset($guildRoles[$discordBot->botID])) {
$rolesTmp = $guildRoles[$discordBot->botID];
if (!isset($guildRoles[$discordBot->botID]['body'])) {
continue;
}
$rolesTmp = $rolesTmp['body'];

$rolesTmp = $guildRoles[$discordBot->botID]['body'];
if (!\is_array($rolesTmp)) {
$rolesTmp = [];
}
Expand All @@ -44,10 +45,17 @@ public function getFormElement($value)
];
}

$realValue = [];
try {
$realValue = \unserialize($value);
} catch (Throwable $e) {
// do nothing
}

WCF::getTPL()->assign([
'bots' => $roles,
'optionName' => $this->optionName,
'value' => \unserialize($value),
'value' => $realValue,
]);

return WCF::getTPL()->fetch('discordRoleMultiSelect');
Expand Down
8 changes: 4 additions & 4 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
<packagename language="de">Discord-API</packagename>
<packagedescription>API to cummincate with Discord.</packagedescription>
<packagedescription language="de">API um mit Discord zu kommunizieren.</packagedescription>
<version>2.5.1</version>
<date>2022-10-21</date>
<version>2.5.2</version>
<date>2024-07-03</date>
<license>https://creativecommons.org/publicdomain/zero/1.0/deed.en</license>
</packageinformation>
<authorinformation>
<author>Hanashi Development</author>
<authorurl>https://hanashi.dev/</authorurl>
</authorinformation>
<requiredpackages>
<requiredpackage minversion="5.5.0">com.woltlab.wcf</requiredpackage>
<requiredpackage minversion="5.5.22">com.woltlab.wcf</requiredpackage>
</requiredpackages>
<excludedpackages>
<excludedpackage version="6.0.0 Alpha 1">com.woltlab.wcf</excludedpackage>
Expand All @@ -30,7 +30,7 @@
<instruction type="option"/>
<instruction type="script">acp/install_dev.hanashi.wsc.discord-api.php</instruction>
</instructions>
<instructions type="update" fromversion="2.5.0">
<instructions type="update" fromversion="2.5.1">
<instruction type="file"/>
</instructions>
</package>

0 comments on commit a27fa30

Please sign in to comment.