Skip to content

Commit a6f8c27

Browse files
authored
Fix ToJSON ChannelType instance (#72)
1 parent d00b35d commit a6f8c27

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

calamity/Calamity/Types/Model/Channel/ChannelType.hs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,19 @@ $(deriveTextShow ''ChannelType)
2828
$(makeFieldLabelsNoPrefix ''ChannelType)
2929

3030
instance Aeson.ToJSON ChannelType where
31-
toJSON t = Aeson.toJSON (fromEnum t)
32-
toEncoding t = Aeson.toEncoding (fromEnum t)
31+
toJSON t = Aeson.Number $ case t of
32+
GuildTextType -> 0
33+
DMType -> 1
34+
GuildVoiceType -> 2
35+
GroupDMType -> 3
36+
GuildCategoryType -> 4
37+
GuildNewsType -> 5
38+
GuildNewsThreadType -> 10
39+
GuildPublicThreadType -> 11
40+
GuildPrivateThreadType -> 12
41+
GuildStageVoiceType -> 13
42+
GuildDirectoryType -> 14
43+
GuildForumType -> 15
3344

3445
instance Aeson.FromJSON ChannelType where
3546
parseJSON = Aeson.withScientific "ChannelType" $ \n -> case toBoundedInteger @Int n of

0 commit comments

Comments
 (0)