Skip to content

Commit 9c2fab9

Browse files
authored
Merge pull request #48 from AlecM33/fix-wildcard-command
fix wildcard command for very beginning of season, add emoji section to readme
2 parents c58e1c6 + d19c219 commit 9c2fab9

File tree

5 files changed

+23
-9
lines changed

5 files changed

+23
-9
lines changed

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,19 @@ The bot is dependent on a short list of environment variables. When these are po
6464
- TOKEN - your bot's authentication token. **Obligatory 'this is sensitive' - be careful where you store it**
6565
- TIME_ZONE - Your chosen time zone. Defaults to EST. Time zone names correspond to the Zone and Link names of the [IANA Time Zone Database](https://www.iana.org/time-zones), such as "UTC", "Asia/Shanghai", "Asia/Kolkata", and "America/New_York". Additionally, time zones can be given as UTC offsets in the format "±hh:mm", "±hhmm", or "±hh", for example as "+01:00", "-2359", or "+23".
6666

67+
### Optional - add emojis!
68+
69+
Discord allows applications to have up to 2,000 custom emojis. I have integrated team logo emojis into the app, to be used with
70+
commands such as `/schedule`:
71+
72+
![schedule with emojis](images/screenshots/schedule_emojis.png)
73+
74+
On the page for your application in the Discord Dev Portal, there is a section for Emojis. There you can upload images.
75+
I recommend you use those I have stored here under /images/spots. Upload all 30, preserving the names. That should be all
76+
that's necessary to start seeing them show up - they will be fetched when the bot starts up.
77+
78+
![emojis dev portal](images/screenshots/emojis_dev_portal.png)
79+
6780
If the bot starts up successfully, the start-up logs look something like the following (subject to your log level):
6881
```
6982
LOG Fri, 28 Jun 2024 20:34:39 GMT : Ready!
17.5 KB
Loading
32.9 KB
Loading

modules/command-util.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -925,22 +925,22 @@ function mapStandings (standings, wildcard = false) {
925925
homeRecord: (teamRecord.record_home
926926
? teamRecord.record_home
927927
: (() => {
928-
const home = teamRecord.records.splitRecords.find(record => record.type === 'home');
929-
return home.wins + '-' + home.losses;
928+
const home = teamRecord.records?.splitRecords?.find(record => record.type === 'home');
929+
return home ? home.wins + '-' + home.losses : '-';
930930
})()),
931931
awayRecord: (teamRecord.record_away
932932
? teamRecord.record_away
933933
: (() => {
934-
const away = teamRecord.records.splitRecords.find(record => record.type === 'away');
935-
return away.wins + '-' + away.losses;
934+
const away = teamRecord.records?.splitRecords?.find(record => record.type === 'away');
935+
return away ? away.wins + '-' + away.losses : '-';
936936
})()),
937937
lastTen: (teamRecord.record_lastTen
938938
? teamRecord.record_lastTen
939939
: (() => {
940-
const l10 = teamRecord.records.splitRecords.find(record => record.type === 'lastTen');
941-
return l10.wins + '-' + l10.losses;
940+
const l10 = teamRecord.records?.splitRecords?.find(record => record.type === 'lastTen');
941+
return l10 ? l10.wins + '-' + l10.losses : '-';
942942
})()),
943-
streak: teamRecord.streak
943+
streak: teamRecord.streak || '-'
944944
};
945945
});
946946
}

modules/interaction-handlers.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,10 @@ module.exports = {
141141
const team = await mlbAPIUtil.team(process.env.TEAM_ID);
142142
const leagueId = team.teams[0].league.id;
143143
const leagueName = team.teams[0].league.name;
144-
const wildcard = (await mlbAPIUtil.wildcard()).records
144+
const leagueStandings = await mlbAPIUtil.wildcard();
145+
const wildcard = leagueStandings.records
145146
.find(record => record.standingsType === 'wildCard' && record.league === leagueId);
146-
const divisionLeaders = (await mlbAPIUtil.wildcard()).records
147+
const divisionLeaders = leagueStandings.records
147148
.find(record => record.standingsType === 'divisionLeaders' && record.league === leagueId);
148149
if (!divisionLeaders || !wildcard) {
149150
await interaction.followUp({

0 commit comments

Comments
 (0)