File tree Expand file tree Collapse file tree 3 files changed +106
-0
lines changed Expand file tree Collapse file tree 3 files changed +106
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import { index } from "@/routes/index";
7
7
import { getGameId } from "@/routes/games/get-game-id" ;
8
8
import { getAsset } from "@/routes/games/get-game-category" ;
9
9
import { getGames } from "@/routes/games/list-games" ;
10
+ import { getChangelog } from "@/routes/discord/changelog" ;
10
11
11
12
const router = AutoRouter ( ) ;
12
13
17
18
. get ( "/game/:gameId/:asset" , errorHandler ( getAsset ) )
18
19
. get ( "/discord/contributors" , errorHandler ( getContributors ) )
19
20
. get ( "/discord/members" , errorHandler ( getMembers ) )
21
+ . get ( "/discord/changelog" , errorHandler ( getChangelog ) )
20
22
. all ( "*" , ( ) : Response => {
21
23
return new Response (
22
24
JSON . stringify ( {
Original file line number Diff line number Diff line change @@ -15,3 +15,78 @@ export interface GuildMember {
15
15
avatar : string ;
16
16
} ;
17
17
}
18
+
19
+ export interface DiscordAPIResponse {
20
+ success : boolean ;
21
+ status : string ;
22
+ path : string ;
23
+ messages : DiscordMessage [ ] ;
24
+ }
25
+ export interface DiscordMessage {
26
+ type : number ;
27
+ content : string ;
28
+ mentions : DiscordUser [ ] ;
29
+ mention_roles : string [ ] ;
30
+ attachments : any [ ] ;
31
+ embeds : any [ ] ;
32
+ timestamp : string ;
33
+ edited_timestamp : string | null ;
34
+ flags : number ;
35
+ components : any [ ] ;
36
+ id : string ;
37
+ channel_id : string ;
38
+ author : DiscordUser ;
39
+ pinned : boolean ;
40
+ mention_everyone : boolean ;
41
+ tts : boolean ;
42
+ reactions ?: DiscordReaction [ ] ;
43
+ message_reference ?: MessageReference ;
44
+ referenced_message ?: DiscordMessage ;
45
+ position ?: number ;
46
+ }
47
+
48
+ export interface DiscordUser {
49
+ id : string ;
50
+ username : string ;
51
+ avatar : string ;
52
+ discriminator : string ;
53
+ public_flags : number ;
54
+ flags : number ;
55
+ banner : string | null ;
56
+ accent_color : number | null ;
57
+ global_name : string | null ;
58
+ avatar_decoration_data : AvatarDecorationData | null ;
59
+ banner_color : string | null ;
60
+ clan : any | null ;
61
+ }
62
+
63
+ export interface AvatarDecorationData {
64
+ asset : string ;
65
+ sku_id : string ;
66
+ expires_at : string | null ;
67
+ }
68
+
69
+ export interface DiscordReaction {
70
+ emoji : {
71
+ id : string | null ;
72
+ name : string ;
73
+ animated ?: boolean ;
74
+ } ;
75
+ count : number ;
76
+ count_details : {
77
+ burst : number ;
78
+ normal : number ;
79
+ } ;
80
+ burst_colors : any [ ] ;
81
+ me_burst : boolean ;
82
+ burst_me : boolean ;
83
+ me : boolean ;
84
+ burst_count : number ;
85
+ }
86
+
87
+ export interface MessageReference {
88
+ type : number ;
89
+ channel_id : string ;
90
+ message_id : string ;
91
+ guild_id : string ;
92
+ }
Original file line number Diff line number Diff line change
1
+ import { responseHeaders } from "@/lib/responseHeaders" ;
2
+ import { DiscordMessage } from "@/lib/types/discord" ;
3
+
4
+ export const getChangelog = async (
5
+ request : Request ,
6
+ env : Env ,
7
+ ctx : ExecutionContext
8
+ ) : Promise < Response > => {
9
+ const CHANNEL_ID = "1112527121848483920" ;
10
+ const API_ENDPOINT = `https://discord.com/api/v10/channels/${ CHANNEL_ID } /messages?limit=15` ;
11
+
12
+ const res = await fetch ( API_ENDPOINT , {
13
+ headers : {
14
+ Authorization : `Bot ${ env . DISCORD_TOKEN } ` ,
15
+ } ,
16
+ } ) ;
17
+
18
+ const messages = ( await res . json ( ) ) as DiscordMessage [ ] ;
19
+
20
+ return new Response (
21
+ JSON . stringify ( {
22
+ success : true ,
23
+ status : "ok" ,
24
+ path : `/discord/changelog` ,
25
+ messages,
26
+ } ) ,
27
+ responseHeaders
28
+ ) ;
29
+ } ;
You can’t perform that action at this time.
0 commit comments