-
Notifications
You must be signed in to change notification settings - Fork 0
/
Config.vb
103 lines (90 loc) · 3.34 KB
/
Config.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
Imports DiscordRPC
Public Class Config
Public hide_on_startup As Boolean = False
Public start_with_windows As Boolean = False
Public lang As String = "en_us"
Public use_beta As Boolean = True
Public use_alpha As Boolean = False
Public rpc As New RPC_Config
End Class
Public Class RPC_Config
Public ClientID As ULong? = 821442553265782844
Public Details As String = "Fully Customizable"
Public State As String
Public LargeImageKey As String = "discorpc"
Public LargeImageText As String = $"DiscoRPC"
Public SmallImageKey As String
Public SmallImageText As String
Public Button_A As RPC_Config_Button = New RPC_Config_Button("Download", "https://github.com/ZaptoInc/DiscoRPC/releases")
Public Button_B As RPC_Config_Button = Nothing
Function CreateRichClient() As DiscordRpcClient
If ClientID.HasValue Then
Dim client As New DiscordRpcClient(Me.ClientID.Value)
Return client
Else
Return Nothing
End If
End Function
Function CreateRichPresence() As RichPresence
Dim pre As New RichPresence
Dim asset = New Assets()
If Not String.IsNullOrWhiteSpace(Me.SmallImageKey) Then
asset.SmallImageKey = Me.SmallImageKey
End If
If Not String.IsNullOrWhiteSpace(Me.SmallImageText) Then
asset.SmallImageText = Me.SmallImageText
End If
If Not String.IsNullOrWhiteSpace(Me.LargeImageKey) Then
asset.LargeImageKey = Me.LargeImageKey
End If
If Not String.IsNullOrWhiteSpace(Me.LargeImageText) Then
asset.LargeImageText = Me.LargeImageText
End If
pre.Assets = asset
Dim buttons As New List(Of Button)
If Button_A IsNot Nothing Then
Try
Dim button_temp As New Button
If Not Uri.IsWellFormedUriString(Button_A.Url, UriKind.Absolute) Then Throw New Exception("not url")
button_temp.Url = Button_A.Url
If String.IsNullOrWhiteSpace(Button_A.Label) Then Throw New Exception("not text")
button_temp.Label = Button_A.Label
buttons.Add(button_temp)
Catch
End Try
End If
If Button_B IsNot Nothing Then
Try
Dim button_temp As New Button
If Not Uri.IsWellFormedUriString(Button_B.Url, UriKind.Absolute) Then Throw New Exception("not url")
button_temp.Url = Button_B.Url
If String.IsNullOrWhiteSpace(Button_B.Label) Then Throw New Exception("not text")
button_temp.Label = Button_B.Label
buttons.Add(button_temp)
Catch ex As Exception
End Try
End If
pre.Buttons = buttons.ToArray
pre.Details = Me.Details
pre.State = Me.State
Return pre
End Function
End Class
Public Class RPC_Config_Button
Public Label As String = Nothing
Public Url As String = Nothing
Sub New()
End Sub
Sub New(Label As String, Url As String)
If Not String.IsNullOrWhiteSpace(Label) Then
Me.Label = Label
Else
Me.Label = Nothing
End If
If Not String.IsNullOrWhiteSpace(Url) Then
Me.Url = Url
Else
Me.Url = Nothing
End If
End Sub
End Class