Skip to content

Commit

Permalink
fixing vlrggapi, removing unused parameters, run betteralign
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyagara committed May 27, 2024
1 parent 2983da8 commit d09a942
Show file tree
Hide file tree
Showing 11 changed files with 179 additions and 193 deletions.
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ This bot periodically sends information about upcoming League of Legends and Val
- `news` command for latest val/lol esports news.
- `recent` command for latest val/lol esports games results.
- `item` command for lol items.
- Cache requests to esports apis in a file to avoid requests when starting up unless its past the post time. (Partially complete)
- Disable button when pressed by a user. (To avoid errors for now, buttons are sent but they are disabled)
- Disable button when pressed by a user. (To avoid errors for now, buttons sent are disabled)

## What data does this bot provide and how?

### Champions and spells (stats, modifiers and notes)

Data from [DataDragon](https://developer.riotgames.com/docs/lol#data-dragon) provided by riot can be sometimes... interesting, take Miss Fortune for example, her ultimate, `Bullet Time`, has apparently a range of 25000, the same range as Ashe's ultimate, a global spell. [CommunityDragon](https://github.com/CommunityDragon/)'s alternative to the DataDragon champion endpoint provides more data, but runs into the same issue in the case of Miss Fortune's ultimate. This leaves the [League of Legends Wiki](https://leagueoflegends.fandom.com/wiki/League_of_Legends_Wiki) as a pretty good source of information.
Data from [DataDragon](https://developer.riotgames.com/docs/lol#data-dragon) provided by riot can be sometimes... interesting, take Miss Fortune for example, her ultimate, `Bullet Time`, has apparently a range of 25000, the same range as Ashe's ultimate, a global spell. [CommunityDragon](https://github.com/CommunityDragon/)'s alternative to the DataDragon champion endpoint provides more data, but runs into the same issue. This leaves the [League of Legends Wiki](https://leagueoflegends.fandom.com/wiki/League_of_Legends_Wiki) as a pretty good source of information.

Using the [lolstaticdata](https://github.com/meraki-analytics/lolstaticdata) tool to gather data from the wiki and normalizing it for this bot's use case (numbers can be string since it will be thrown into Discord Embeds anyway) and the CommunityDragon's CDN to get links for some static data, we can get some pretty good information, nothing ground breaking or that "discards" a visit to the wiki (which is why we keep links to the wiki everywhere).

Expand All @@ -42,6 +41,9 @@ For League of Legends, this bot uses the unofficial [LolEsports](https://lolespo
This bot requires the data provided from [lolstaticdata](https://github.com/meraki-analytics/lolstaticdata). For now, only champion data is needed, so you can just run `python -m lolstaticdata.champions`.

> [!WARNING]
> When a new League of Legends patch is out, please try to not constantly update the data, when a new champion is out for example, check if the wiki has enough information on it to justify gathering all data again.
After copying the champions data folder to the root of the project, a champion should have a path like `./data/champions/Aatrox.json`.

Run `go run ./normalize`, this will create a folder with a path for a champion like `./data/champions/normalized/Aatrox.json`.
Expand Down Expand Up @@ -69,10 +71,6 @@ If mod_roles is empty, anyone will be able to use the `update` option from the `

Now run the bot with the flag `-register` once, this will **overwrite all guild commands** to the specified guild in the config file, after that you can run the bot without specifying any flag.

## Updating

When a new League of Legends patch is out, just repeat the process of gathering and normalizing the data, please try to not constantly update the data, when a new champion is out for example, check if the wiki has enough information on it to justify gathering all data again.

## Disclaimer

discord-esports isn't endorsed by Riot Games and doesn't reflect the views or opinions of Riot Games or anyone officially involved in producing or managing Riot Games properties. Riot Games, and all associated properties are trademarks or registered trademarks of Riot Games, Inc.
10 changes: 5 additions & 5 deletions data.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,27 +83,27 @@ func loadWikiData() error {

for i, spell := range champion.Spells.Passive {
spellsInfo[champion.Key] = append(spellsInfo[champion.Key], createSpellInfo(&spell, "P", i))
spellsEmbeds[champion.Key]["P"] = append(spellsEmbeds[champion.Key]["P"], createChampionSpellEmbed(&champion, &spell, "P"))
spellsEmbeds[champion.Key]["P"] = append(spellsEmbeds[champion.Key]["P"], createChampionSpellEmbed(&champion, &spell))
}

for i, spell := range champion.Spells.Q {
spellsInfo[champion.Key] = append(spellsInfo[champion.Key], createSpellInfo(&spell, "Q", i))
spellsEmbeds[champion.Key]["Q"] = append(spellsEmbeds[champion.Key]["Q"], createChampionSpellEmbed(&champion, &spell, "Q"))
spellsEmbeds[champion.Key]["Q"] = append(spellsEmbeds[champion.Key]["Q"], createChampionSpellEmbed(&champion, &spell))
}

for i, spell := range champion.Spells.W {
spellsInfo[champion.Key] = append(spellsInfo[champion.Key], createSpellInfo(&spell, "W", i))
spellsEmbeds[champion.Key]["W"] = append(spellsEmbeds[champion.Key]["W"], createChampionSpellEmbed(&champion, &spell, "W"))
spellsEmbeds[champion.Key]["W"] = append(spellsEmbeds[champion.Key]["W"], createChampionSpellEmbed(&champion, &spell))
}

for i, spell := range champion.Spells.E {
spellsInfo[champion.Key] = append(spellsInfo[champion.Key], createSpellInfo(&spell, "E", i))
spellsEmbeds[champion.Key]["E"] = append(spellsEmbeds[champion.Key]["E"], createChampionSpellEmbed(&champion, &spell, "E"))
spellsEmbeds[champion.Key]["E"] = append(spellsEmbeds[champion.Key]["E"], createChampionSpellEmbed(&champion, &spell))
}

for i, spell := range champion.Spells.R {
spellsInfo[champion.Key] = append(spellsInfo[champion.Key], createSpellInfo(&spell, "R", i))
spellsEmbeds[champion.Key]["R"] = append(spellsEmbeds[champion.Key]["R"], createChampionSpellEmbed(&champion, &spell, "R"))
spellsEmbeds[champion.Key]["R"] = append(spellsEmbeds[champion.Key]["R"], createChampionSpellEmbed(&champion, &spell))
}

championsEmbeds[champion.Key] = createChampionEmbed(&champion)
Expand Down
2 changes: 1 addition & 1 deletion esports.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func EsportsCommand(session *discordgo.Session, interaction *discordgo.Interacti
game := optionMap["game"].StringValue()

if optionMap["update"] != nil {
if !hasPermissions(session, interaction) {
if !hasPermissions(interaction) {
return
}

Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module discord-esports
go 1.20

require (
github.com/bwmarrin/discordgo v0.27.1
go.uber.org/zap v1.26.0
golang.org/x/text v0.13.0
github.com/bwmarrin/discordgo v0.28.1
go.uber.org/zap v1.27.0
golang.org/x/text v0.15.0
)

require (
Expand Down
14 changes: 7 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
github.com/bwmarrin/discordgo v0.27.1 h1:ib9AIc/dom1E/fSIulrBwnez0CToJE113ZGt4HoliGY=
github.com/bwmarrin/discordgo v0.27.1/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY=
github.com/bwmarrin/discordgo v0.28.1 h1:gXsuo2GBO7NbR6uqmrrBDplPUx2T3nzu775q/Rd1aG4=
github.com/bwmarrin/discordgo v0.28.1/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo=
go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so=
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
Expand All @@ -21,7 +21,7 @@ golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
75 changes: 40 additions & 35 deletions lol.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,49 +11,54 @@ import (
)

type LOLEsportsLeagueResponse struct {
Data struct {
Leagues []struct {
ID string `json:"id"`
Slug string `json:"slug"`
Name string `json:"name"`
Region string `json:"region"`
Image string `json:"image"`
Priority int `json:"priority"`
DisplayPriority struct {
Position int `json:"position"`
Status string `json:"status"`
} `json:"displayPriority"`
} `json:"leagues"`
} `json:"data"`
Data LOLEsportsLeagueData `json:"data"`
}

type LOLEsportsLeagueData struct {
Leagues []LOLEsportsLeague `json:"leagues"`
}

type LOLEsportsLeague struct {
ID string `json:"id"`
}

type LOLEsportsEventListResponse struct {
Data struct {
Esports struct {
Events []struct {
StartTime string `json:"startTime"`
Match struct {
Teams []struct {
Code string `json:"code"`
Image string `json:"image"`
} `json:"teams"`
} `json:"match"`
League struct {
ID string `json:"id"`
Slug string `json:"slug"`
Name string `json:"name"`
} `json:"league"`
} `json:"events"`
} `json:"esports"`
} `json:"data"`
Data LOLEsportsEventData `json:"data"`
}

type LOLEsportsEventData struct {
Esports LOLEsportsEventEsports `json:"esports"`
}

type LOLEsportsEventEsports struct {
Events []LOLEsportsEvent `json:"events"`
}

type LOLEsportsEvent struct {
StartTime string `json:"startTime"`
League LOLEsportsEventLeague `json:"league"`
Match LOLEsportsEventMatch `json:"match"`
}

type LOLEsportsEventLeague struct {
Slug string `json:"slug"`
Name string `json:"name"`
}

type LOLEsportsEventMatch struct {
Teams []LOLEsportsEventMatchTeam `json:"teams"`
}

type LOLEsportsEventMatchTeam struct {
Code string `json:"code"`
}

type LOLEsportsLeagueSchedule struct {
League string
URL string
Time string
TeamA string
TeamB string
League string
Time string
URL string
}

func updateLOLEsportsData() error {
Expand Down
34 changes: 17 additions & 17 deletions models/champion.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
package models

type Champion struct {
ID int `json:"id"`
Key string `json:"key"`
Name string `json:"name"`
FullTitle string `json:"fullTitle"`
Icon string `json:"icon"`
Lore string `json:"lore"`
Resource string `json:"resource"`
AttackType string `json:"attackType"`
AdaptiveType string `json:"adaptiveType"`
Roles []string `json:"roles"`
PatchLastChanged string `json:"patchLastChanged"`
OfficialPage string `json:"officialPage"`
WikiPage string `json:"wikiPage"`
// ChampionStats also include per level number when available
Stats ChampionStats `json:"stats"`
Spells ChampionSpells `json:"spells"`
Stats ChampionStats `json:"stats"`
Key string `json:"key"`
Name string `json:"name"`
FullTitle string `json:"fullTitle"`
Icon string `json:"icon"`
Lore string `json:"lore"`
Resource string `json:"resource"`
AttackType string `json:"attackType"`
AdaptiveType string `json:"adaptiveType"`
PatchLastChanged string `json:"patchLastChanged"`
OfficialPage string `json:"officialPage"`
WikiPage string `json:"wikiPage"`
Spells ChampionSpells `json:"spells"`
Roles []string `json:"roles"`
ID int `json:"id"`
}

type ChampionStats struct {
Expand Down Expand Up @@ -46,7 +46,6 @@ type ChampionSpell struct {
Icon string `json:"icon"`
Video string `json:"video"`
WikiPage string `json:"wikiPage"`
Effects []ChampionSpellEffect `json:"effects"`
AffectedByCDR string `json:"affectedByCDR"`
Cost string `json:"cost"`
Cooldown string `json:"cooldown"`
Expand All @@ -56,13 +55,14 @@ type ChampionSpell struct {
Resource string `json:"resource"`
DamageType string `json:"damageType"`
Projectile string `json:"projectile"`
Notes []string `json:"notes"`
Speed string `json:"speed"`
Width string `json:"width"`
Angle string `json:"angle"`
CastTime string `json:"castTime"`
EffectRadius string `json:"effectRadius"`
TargetRange string `json:"targetRange"`
Effects []ChampionSpellEffect `json:"effects"`
Notes []string `json:"notes"`
}

type ChampionSpellEffect struct {
Expand Down
Loading

0 comments on commit d09a942

Please sign in to comment.