Add battlenet and domain, improve rendering

This commit is contained in:
Melon 2023-09-22 02:04:04 +01:00
parent d427e84371
commit 5bac14459f
Signed by: melon
GPG Key ID: 6C9D970C50D26A25
4 changed files with 120 additions and 101 deletions

View File

@ -108,27 +108,27 @@ func (m *Module) homepage(rw http.ResponseWriter, _ *http.Request, state *utils.
return
}
guildIcons := make([]template.HTMLAttr, len(myGuilds))
guildIcons := make([]string, len(myGuilds))
for i, j := range myGuilds {
var a discordgo.Guild
a.ID = j.ID
a.Icon = j.Icon
guildIcons[i] = template.HTMLAttr(fmt.Sprintf("src=\"%s\"", a.IconURL()))
guildIcons[i] = a.IconURL()
}
err = tmp.Execute(rw, struct {
User *discordgo.User
UserAccent string
Avatar template.HTMLAttr
Banner template.HTMLAttr
Avatar string
Banner string
Guilds []*discordgo.UserGuild
GuildIcons []template.HTMLAttr
GuildIcons []string
Connections []*discordgo.UserConnection
}{
User: myUser,
UserAccent: fmt.Sprintf("#%06x", myUser.AccentColor),
Avatar: template.HTMLAttr(fmt.Sprintf("src=\"%s\"", myUser.AvatarURL("256"))),
Banner: template.HTMLAttr(fmt.Sprintf("src=\"%s\"", myUser.BannerURL("256"))),
Avatar: myUser.AvatarURL("256"),
Banner: myUser.BannerURL("256"),
Guilds: myGuilds,
GuildIcons: guildIcons,
Connections: myConns,
@ -180,6 +180,8 @@ func (m *Module) loginPage(rw http.ResponseWriter, req *http.Request, state *uti
func connectedLinkFunc(a *discordgo.UserConnection) string {
switch a.Type {
case "domain":
return "https://" + a.Name
case "github":
return "https://github.com/" + a.Name
case "reddit":
@ -192,10 +194,8 @@ func connectedLinkFunc(a *discordgo.UserConnection) string {
return "https://www.twitch.tv/" + a.Name
case "twitter":
return "https://twitter.com/" + a.Name
case "xbox":
return "javascript:alert('No link to XBox profiles')"
case "youtube":
return "https://www.youtube.com/channel/" + a.ID
}
return "javascript:alert('Unknown profile type')"
return ""
}

View File

@ -0,0 +1,3 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M18.94 7.90321C15.904 6.49921 11.536 5.60721 7.42802 5.93921C7.63202 4.57921 8.14402 3.63121 8.97602 3.43121C10.124 3.15521 11.376 3.91121 12.568 5.28321C13.348 5.38321 14.276 5.56321 14.924 5.71121C12.748 1.61921 9.82802 -0.672789 7.60802 0.175211C5.92002 0.819211 5.05602 3.14321 5.16002 6.26721C2.96002 6.73521 1.24401 7.56721 0.144012 8.76321C0.0880121 8.82721 -0.0359881 8.99121 0.00801199 9.06721C0.044012 9.12721 0.152012 9.05921 0.204012 9.02721C1.47601 8.13521 3.10802 7.65521 5.23202 7.35121C5.53602 10.6832 6.94402 14.9112 9.28802 18.3032C8.00802 18.8072 6.93202 18.8392 6.34402 18.2152C5.53202 17.3592 5.56002 15.8952 6.15202 14.1752C5.84802 13.4472 5.54002 12.5552 5.34802 11.9232C2.88402 15.8552 2.35601 19.5312 4.20002 21.0312C5.60402 22.1712 8.04802 21.7592 10.7 20.1072C12.204 21.7792 13.784 22.8472 15.368 23.1992C15.452 23.2152 15.656 23.2432 15.7 23.1672C15.736 23.1072 15.62 23.0432 15.568 23.0192C14.16 22.3632 12.928 21.1912 11.604 19.5032C14.34 17.5752 17.296 14.2392 19.06 10.5152C20.136 11.3752 20.7 12.2872 20.456 13.1112C20.12 14.2432 18.84 14.9512 17.052 15.2952C16.572 15.9232 15.956 16.6352 15.504 17.1192C20.136 17.2792 23.584 15.8992 23.96 13.5552C24.248 11.7712 22.664 9.85921 19.908 8.38721C20.604 6.24721 20.74 4.34721 20.252 2.79921C20.224 2.71921 20.148 2.52721 20.056 2.52721C19.988 2.52721 19.988 2.65921 19.992 2.71521C20.136 4.25921 19.74 5.91521 18.94 7.90321ZM10.408 17.7712C8.44802 14.6272 7.32002 10.9232 7.32402 7.17921C11.028 7.05521 14.8 7.92721 18.04 9.80721C16.296 13.0752 13.656 15.9072 10.408 17.7712Z" fill="#3F8FF7"/>
</svg>

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -0,0 +1,5 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M12 2C6.48 2 2 6.48 2 12C2 17.52 6.48 22 12 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 12 2ZM11 19.93C7.05 19.44 4 16.08 4 12C4 11.38 4.08 10.79 4.21 10.21L9 15V16C9 17.1 9.9 18 11 18V19.93ZM17.9 17.39C17.64 16.58 16.9 16 16 16H15V13C15 12.45 14.55 12 14 12H8V10H10C10.55 10 11 9.55 11 9V7H13C14.1 7 15 6.1 15 5V4.59C17.93 5.78 20 8.65 20 12C20 14.08 19.2 15.97 17.9 17.39Z"
fill="#F2F3F5" />
</svg>

After

Width:  |  Height:  |  Size: 525 B

View File

@ -14,12 +14,21 @@
}
.page-content {
}
.page-row {
display: flex;
flex-direction: row;
align-items: flex-start;
flex-wrap: wrap;
}
.page-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}
.connected-accounts li a[data-is-revoked=true] {
border: 2px solid red;
}
@ -41,102 +50,104 @@
<body>
<h1>Discord | <a href="/">Melon Tools</a></h1>
<div class="page-content">
<div>
{{with .User}}
<p>My User: {{.Username}}#{{.Discriminator}}</p>
<ul>
<li>ID: {{.ID}}</li>
<li>Email: {{.Email}}</li>
<li>Username: {{.Username}}</li>
<li>Avatar: <img {{$.Avatar}} alt="User Avatar"/></li>
<li>Locale: {{.Locale}}</li>
<li>Discriminator: {{.Discriminator}}</li>
<li>Verified: {{.Verified}}</li>
<li>MFA: {{.MFAEnabled}}</li>
<li>Banner: <img {{$.Banner}} alt="User Banner"/></li>
<li>Accent Color: {{$.UserAccent}} <span class="colour-block"
style="background-color: {{$.UserAccent}}">&nbsp;</span>
</li>
<li>Bot: {{.Bot}}</li>
<li>Premium: {{.PremiumType}}</li>
<li>System: {{.System}}</li>
</ul>
{{end}}
</div>
<div>
{{with .User.PublicFlags}}
<p>My Flags:</p>
<ul>
{{if checkFlag . 1}}
<li>Discord Employee</li>
{{end}}
{{if checkFlag . 2}}
<li>Discord Partner</li>
{{end}}
{{if checkFlag . 4}}
<li>Hype Squad Events</li>
{{end}}
{{if checkFlag . 8}}
<li>Bug Hunter Level 1</li>
{{end}}
{{if checkFlag . 64}}
<li>House Bravery</li>
{{end}}
{{if checkFlag . 128}}
<li>House Brilliance</li>
{{end}}
{{if checkFlag . 256}}
<li>House Balance</li>
{{end}}
{{if checkFlag . 512}}
<li>Early Supporter</li>
{{end}}
{{if checkFlag . 1024}}
<li>Team User</li>
{{end}}
{{if checkFlag . 4096}}
<li>System</li>
{{end}}
{{if checkFlag . 16384}}
<li>Bug Hunter Level 2</li>
{{end}}
{{if checkFlag . 65536}}
<li>Verified Bot</li>
{{end}}
{{if checkFlag . 131072}}
<li>Verified Bot Developer</li>
{{end}}
{{if checkFlag . 262144}}
<li>Discord Certified Moderator</li>
{{end}}
{{if checkFlag . 524288}}
<li>Bot HTTP interactions</li>
{{end}}
{{if checkFlag . 4194304}}
<li>Active Developer</li>
{{end}}
</ul>
{{end}}
</div>
<div>
<p>Connections ({{len .Connections}}):</p>
<ul class="connected-accounts">
{{range .Connections}}
<li>
<a href="{{connectedLink .}}" target="_blank" data-is-revoked="{{.Revoked}}">
<img src="/discord/assets/icon/{{.Type}}.svg"/>
<span>{{.Name}}</span>
</a>
</li>
<div class="page-row">
<div>
{{with .User}}
<p>My User: {{.Username}}#{{.Discriminator}}</p>
<ul>
<li>ID: {{.ID}}</li>
<li>Email: {{.Email}}</li>
<li>Username: {{.Username}}</li>
<li>Avatar: <img src="{{$.Avatar}}" alt="User Avatar"/></li>
<li>Locale: {{.Locale}}</li>
<li>Discriminator: {{.Discriminator}}</li>
<li>Verified: {{.Verified}}</li>
<li>MFA: {{.MFAEnabled}}</li>
<li>Banner: <img src="{{$.Banner}}" alt="User Banner"/></li>
<li>Accent Color: {{$.UserAccent}} <span class="colour-block"
style="background-color: {{$.UserAccent}}">&nbsp;</span>
</li>
<li>Bot: {{.Bot}}</li>
<li>Premium: {{.PremiumType}}</li>
<li>System: {{.System}}</li>
</ul>
{{end}}
</ul>
</div>
<div>
{{with .User.PublicFlags}}
<p>My Flags:</p>
<ul>
{{if checkFlag . 1}}
<li>Discord Employee</li>
{{end}}
{{if checkFlag . 2}}
<li>Discord Partner</li>
{{end}}
{{if checkFlag . 4}}
<li>Hype Squad Events</li>
{{end}}
{{if checkFlag . 8}}
<li>Bug Hunter Level 1</li>
{{end}}
{{if checkFlag . 64}}
<li>House Bravery</li>
{{end}}
{{if checkFlag . 128}}
<li>House Brilliance</li>
{{end}}
{{if checkFlag . 256}}
<li>House Balance</li>
{{end}}
{{if checkFlag . 512}}
<li>Early Supporter</li>
{{end}}
{{if checkFlag . 1024}}
<li>Team User</li>
{{end}}
{{if checkFlag . 4096}}
<li>System</li>
{{end}}
{{if checkFlag . 16384}}
<li>Bug Hunter Level 2</li>
{{end}}
{{if checkFlag . 65536}}
<li>Verified Bot</li>
{{end}}
{{if checkFlag . 131072}}
<li>Verified Bot Developer</li>
{{end}}
{{if checkFlag . 262144}}
<li>Discord Certified Moderator</li>
{{end}}
{{if checkFlag . 524288}}
<li>Bot HTTP interactions</li>
{{end}}
{{if checkFlag . 4194304}}
<li>Active Developer</li>
{{end}}
</ul>
{{end}}
</div>
<div>
<p>Connections ({{len .Connections}}):</p>
<ul class="connected-accounts">
{{range .Connections}}
<li>
<a {{if .}}href="{{connectedLink .}}"{{end}} target="_blank" data-is-revoked="{{.Revoked}}">
<img src="/discord/assets/icon/{{.Type}}.svg" alt="Icon for {{.Type}}"/>
<span>{{.Name}}</span>
</a>
</li>
{{end}}
</ul>
</div>
</div>
<div>
<div class="page-row">
<p>Guilds ({{len .Guilds}}):</p>
<div class="page-content guilds">
<div class="page-grid guilds">
{{range $k, $v := .Guilds}}
<div class="guild-item">
<div><img {{index $.GuildIcons $k}}/></div>
<div><img src="{{index $.GuildIcons $k}}" alt="Icon for {{$v.Name}}"/></div>
<div>{{$v.Name}}</div>
<div>@*{{$v.ID}}</div>
</div>