@@ -4,82 +4,45 @@ namespace Discord_Stream_Notify_Bot.SharedService
44{
55 public class EmojiService : IInteractionService
66 {
7- // 好像要把 Emote Id 給拉到 BotConfig 設定還是怎樣的
8- public Emote YouTubeEmote
7+ public Emote YouTubeEmote { get ; private set ; }
8+ public Emote PayPalEmote { get ; private set ; }
9+ public Emote ECPayEmote { get ; private set ; }
10+
11+ private readonly DiscordSocketClient _client ;
12+
13+ public EmojiService ( DiscordSocketClient client , BotConfig botConfig )
914 {
10- get
15+ _client = client ;
16+
17+ try
1118 {
12- #if ! RELEASE
13- return null ;
14- #endif
15- if ( youTubeEmote == null )
16- {
17- try
18- {
19- Task . Run ( async ( ) => youTubeEmote = await _client . GetApplicationEmoteAsync ( 1265158558299848827 ) ) ;
20- }
21- catch ( Exception ex )
22- {
23- Log . Error ( $ "無法取得YouTube Emote: { ex } ") ;
24- youTubeEmote = null ;
25- }
26- }
27- return youTubeEmote ;
19+ YouTubeEmote = _client . GetApplicationEmoteAsync ( botConfig . YouTubeEmoteId ) . GetAwaiter ( ) . GetResult ( ) ;
2820 }
29- }
30-
31- public Emote PatreonEmote
32- {
33- get
21+ catch ( Exception ex )
3422 {
35- #if ! RELEASE
36- return null ;
37- #endif
38- if ( patreonEmote == null )
39- {
40- try
41- {
42- Task . Run ( async ( ) => patreonEmote = await _client . GetApplicationEmoteAsync ( 1265158902962458769 ) ) ;
43- }
44- catch ( Exception ex )
45- {
46- Log . Error ( $ "無法取得Patreon Emote: { ex } ") ;
47- patreonEmote = null ;
48- }
49- }
50- return patreonEmote ;
23+ Log . Error ( $ "無法取得 YouTube Emote: { ex } ") ;
24+ YouTubeEmote = null ;
5125 }
52- }
5326
54- public Emote PayPalEmote
55- {
56- get
27+ try
5728 {
58- #if ! RELEASE
59- return null ;
60- #endif
61- if ( payPalEmote == null )
62- {
63- try
64- {
65- Task . Run ( async ( ) => payPalEmote = await _client . GetApplicationEmoteAsync ( 1265158658015236107 ) ) ;
66- }
67- catch ( Exception ex )
68- {
69- Log . Error ( $ "無法取得PayPal Emote: { ex } ") ;
70- payPalEmote = null ;
71- }
72- }
73- return payPalEmote ;
29+ PayPalEmote = _client . GetApplicationEmoteAsync ( botConfig . PayPalEmoteId ) . GetAwaiter ( ) . GetResult ( ) ;
30+ }
31+ catch ( Exception ex )
32+ {
33+ Log . Error ( $ "無法取得 PayPal Emote: { ex } ") ;
34+ PayPalEmote = null ;
7435 }
75- }
76-
77- private Emote youTubeEmote , patreonEmote , payPalEmote ;
78- private readonly DiscordSocketClient _client ;
7936
80- public EmojiService ( DiscordSocketClient client )
81- {
82- _client = client ;
37+ try
38+ {
39+ ECPayEmote = _client . GetApplicationEmoteAsync ( botConfig . ECPayEmoteId ) . GetAwaiter ( ) . GetResult ( ) ;
40+ }
41+ catch ( Exception ex )
42+ {
43+ Log . Error ( $ "無法取得 ECPay Emote: { ex } ") ;
44+ ECPayEmote = null ;
45+ }
8346 }
8447 }
8548}
0 commit comments