Giter Club home page Giter Club logo

nhl-discord-bot's Introduction

Hiya ๐Ÿ‘‹

My name is Con-r Mah-r, (conrmahr)! I'm a Lead Software Developer focusing on Fullstack Development, Frontend Development, Open-Source, and Mentorship. I love anything with HTML, CSS, JavaScript, or BBQ Sauce in it.

๐Ÿ”— Find me on the web:

nhl-discord-bot's People

Contributors

conrmahr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

nhl-discord-bot's Issues

Simplify default player and team stats outputs

Is your feature request related to a problem? Please describe.
Simplify the default player and team stats embed output of columns. It currently takes up too much space for a default command.

Describe the ideal solution
Change player fields to only Games, TOI, Goals, Assists, Points, +/- and team stats to only Games, Record, Points, P%, GF/GP, GA/GP. Move Season field next to player name. Add flag -advanced to output all available stats.

Describe alternatives you've considered
Use md format with manual ascii spacing.

Additional context
Inspired by the need for other formats such as #23 and filtering stats.

Add command for officials information

Is your feature request related to a problem? Please describe.
Utilize the NHL Records API /officials end points so I can identify which ref is blind.

Describe the ideal solution
Create a command official . Output an embed with active, Birth City, Birth Country, Name, First Playoff Game, First Regular Game, Headshot, Official Type, Sweater Number.

Describe alternatives you've considered
Brute forced the officials api end point on exact matches..

Additional context
https://records.nhl.com/site/api/officials

...
{
  "id": 2071,
  "active": true,
  "associationUrl": "http://www.nhlofficials.com/nhl-officials/view/68",
  "birthCity": "Hampton",
  "countryCode": "CAN",
  "firstName": "Tim",
  "firstPlayoffGameId": 2001030171,
  "firstRegularGameId": 1999020105,
  "headshot_url": "https://secure.nhl.com/photos/officials/cutouts/2071.png",
  "lastName": "Peel",
  "officialType": "Referee",
  "officialsSchemaId": 10115,
  "referreeAssociationId": 68,
  "stateProvinceCode": "NB",
  "sweaterNumber": 20,
  "thumb_url": "https://secure.nhl.com/photos/officials/thumbs/2071.png"
}
...

Allow localization to be set by users

Is your feature request related to a problem? Please describe.
Games outside of North America can have misleading game dates. Allow localization to be set by user.

Describe the ideal solution
Define a default timezone in config.json to use and also allow end-users to override it with on-demand with a flag a -timezone=. Target game, nhl, official, player, and world.

Describe alternatives you've considered
None considered.

Additional context
https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

Discord app doesn't respect embed field line breaks

Please describe the problem you are having in as much detail as possible:
When multiple games return from the API using the nhl command, Discord iOS app doesn't respect embed field line breaks and bunches all games with 1 nbsp. It is working as excepted in the Discord web and macOS clients.

Include a reproducible code sample here, if possible:

function getScores(games) {
	return games.map(game => {

		function isBold(w, l) {
			if(w > l) {
				return '**';
			}
			else {
				return '';
			}
		}

		function formatPeriod(t, p) {
			const possibleTime = { Final: 'F', END: '0:00' };
			const remain = possibleTime[t] || t;
			const possibleSpacer = { OT: '/', SO: '/' };
			const spacer = possibleSpacer[p] || '';
			let ordinal = p;
			if (remain === 'F' && p === '3rd') {
				ordinal = '';
				console.log(true);
			}

			return `(${remain}${spacer}${ordinal})`;
		}

		const { status: { statusCode }, teams: { away, home }, linescore, broadcasts, venue } = game;
		const awayTeam = teams.find(o => o.id === away.team.id).abbreviation;
		const homeTeam = teams.find(o => o.id === home.team.id).abbreviation;
		const awayBB = isBold(away.score, home.score);
		const homeBB = isBold(home.score, away.score);
		let tv = '';
		let arena = '';
		if (broadcasts) {
			const channels = broadcasts.map(i => i.name).join(', ');
			tv = ':tv: [' + channels + ']';
		}
		else if (flagBroadcasts) {
			tv = ':tv: :flag_ca:';
		}
		if (venue && flagVenue) {
			arena = ':stadium: [' + venue.name + ']';
		}

		if (statusCode < 3 || flagHide) {
			const gameTimeEST = moment(game.gameDate).tz('America/New_York').format('h:mm A z');
			const gameTime = flagHide ? `${formatPeriod(linescore.currentPeriodTimeRemaining, linescore.currentPeriodOrdinal)}` : gameTimeEST;
			return `${awayTeam} @ ${homeTeam} ${gameTime} ${arena} ${tv}`;
		}
		else if (statusCode > 2 && statusCode < 5) {
			const awayPP = linescore.teams.away.powerPlay ? '[*PP*]' : '';
			const homePP = linescore.teams.home.powerPlay ? '[*PP*]' : '';
			const awayEN = linescore.teams.away.goaliePulled ? '[*EN*]' : '';
			const homeEN = linescore.teams.home.goaliePulled ? '[*EN*]' : '';
			return `${awayTeam} ${away.score} ${awayPP} ${awayEN} ${homeTeam} ${home.score} ${homePP} ${homeEN} ${formatPeriod(linescore.currentPeriodTimeRemaining, linescore.currentPeriodOrdinal)} ${arena} ${tv}`;
		}
		else if (statusCode > 5 && statusCode < 8) {
			return `${awayBB}${awayTeam} ${away.score}${awayBB} ${homeBB}${homeTeam} ${home.score}${homeBB} ${formatPeriod(linescore.currentPeriodTimeRemaining, linescore.currentPeriodOrdinal)} ${arena} ${tv}`;
		}
		else if (statusCode === 9) {
			return `${awayTeam} @ ${homeTeam} PPD`;
		}
	}).join('\n');
}

Further details:

  • nhl-discord-bot version: 0.3.0

  • Node.js version: 12.14.0

  • Operating system: iOS and Android

  • Priority this issue should have: Low

  • I have also tested the issue on latest master, commit hash:

Add command for IIHF tourneys

Is your feature request related to a problem? Please describe.
Utilize the IIHF API /GetLatestScoresState endpoint so I can get scores for IIHF tourneys with NHL players.

Describe the ideal solution
Create a command iihf with m, m20, m18, w, w18 as arguments.

Describe alternatives you've considered
Scape IIHF.com website for scores.

Additional context
http://realtime.iihf.com/gamestate/GetLatestScoresState/503

  {
    "HomeTeam": {
      "Points": "0",
      "TeamCode": "SUI"
    },
    "GuestTeam": {
      "Points": "0",
      "TeamCode": "SVK"
    },
    "Date": null,
    "GameDateTime": "2020-12-25T12:00:00",
    "GameDateTimeUTC": "2020-12-25T19:00:00Z",
    "EventStatus": "2",
    "Venue": "Rogers Place",
    "VenueCode": "EDM",
    "PhaseId": "PreliminaryRound",
    "Group": "A",
    "Time": null,
    "Status": "UPCOMING",
    "GameNumber": "1",
    "GameId": "9182",
    "TimeOffset": "GMT-7",
    "TimeOffsetNum": -7
  }

chore(Deps): discord.js v12

Please describe the changes this PR makes and why it should be merged:

Discord has announced breaking API changes that will not be implemented into discord.js version 11. We expect this to happen around October 2020. Along with this we decided to no longer maintain bug fixes or new features for version 11 of discord.js. Please update your bot to version 12 at your earliest convenience.

  • Bump discord.js from v11 to 12

Status

  • Code changes have been tested against the NHL API, or there are no code changes

Semantic versioning classification:

  • This PR changes the app's interface (methods or parameters added)
    • This PR includes breaking changes (methods removed or renamed, parameters moved or removed)
  • This PR only includes non-code changes, like changes to documentation, README, etc.

Add scoring & penalties flags to game command

Is your feature request related to a problem? Please describe.
See scoring or penalty summaries of a live or past game.

Describe the ideal solution
Create flags -scoring and -penalties to fetch /feed/live or /content endpoints.

Describe alternatives you've considered
Scrape the html game summary page.

Additional context

Add Cap information

Is your feature request related to a problem? Please describe.

Describe the ideal solution
I would like a command ($c ) that shows me their current contract situation. This should include
Team
Player Name
Signing Date
yearly breakdown of contract so it can show NMC/NTC etc per year.
Pending contract status (RFA/UFA/ group 6 ufa/10.2c RFA)

Describe alternatives you've consideredposting cap friendly links, which is cumbersome.

Additional context
Add any other context or screenshots about the feature request here.

ISSUE_TEMPLATES have discord.js text

Please describe the problem you are having in as much detail as possible:
Text not updated after copying ISSUE_TEMPLATES folder from discordjs/discord.js repo.

Include a reproducible code sample here, if possible:

---
about: Report incorrect or unexpected behaviour of discord.js
---

Further details:

  • nhl-discord-bot version: 0.3.0

  • Node.js version: 12.14.0

  • Operating system: macOS

  • Priority this issue should have: Low

  • I have also tested the issue on latest master, commit hash:

Add PIM to -o flag

Is your feature request related to a problem? Please describe.
no

Describe the ideal solution
adding PIM to the $p -o flag, to align with the stats that show when you do use $p -y

Describe alternatives you've considered
not asking, but being sarcastic about it.

Additional context
Thanks.

Add commands for player stats

Is your feature request related to a problem? Please describe.
Utilize the NHL API player stat types end points so I can show much a player sucks.

Describe the ideal solution
Create a command player with flags -season -playoffs -career and use Google Search API to have a fuzzy search to grab player ids.

Describe alternatives you've considered
Used cmds for each stat type and https://suggest.svc.nhl.com/svc/suggest/v1/minactiveplayer for name lookup.

Additional context
https://statsapi.web.nhl.com/api/v1/statTypes

[ {
  "displayName" : "careerRegularSeason"
}, {
  "displayName" : "careerPlayoffs"
}, {
  "displayName" : "statsSingleSeason"
}, {
  "displayName" : "statsSingleSeasonPlayoffs"
}, {
  "displayName" : "gameLog"
}, {
  "displayName" : "playoffGameLog"
} ]

Add command for team stats

Is your feature request related to a problem? Please describe.
Utilize the NHL API player stat types end points so I can show much a player sucks.

Describe the ideal solution
Create a command team with flags -season -playoffs and pass a YYYY for a season.

Describe alternatives you've considered
None.

Additional context
https://statsapi.web.nhl.com/api/v1/statTypes

[ {
  "displayName" : "statsSingleSeason"
}, {
  "displayName" : "statsSingleSeasonPlayoffs"
} ]

Game in-progess has a missing spacer and is undefined

Please describe the problem you are having in as much detail as possible:
As reported by @notchristophermeisner, the formatPeriod() function is not outputting the / spacer for live games. Also there's a console.log() line that needs to be removed.

Include a reproducible code sample here, if possible:

function formatPeriod(t, p) {
	const possibleTime = { Final: 'F', END: '0:00' };
	const remain = possibleTime[t] || t;
	const possibleSpacer = { OT: '/', SO: '/' };
	const spacer = possibleSpacer[p] || '';
	let ordinal = p;
	if (remain === 'F' && p === '3rd') {
		ordinal = '';
		console.log(true);
	}

	return `(${remain}${spacer}${ordinal})`;
}

Further details:

  • nhl-discord-bot version: 0.3.0

  • Node.js version: 12.14.0

  • Operating system: macOS

  • Priority this issue should have: High

  • I have also tested the issue on latest master, commit hash:

Add command for draft information

Is your feature request related to a problem? Please describe.
Utilize the NHL API /draft end point so I can look back on all the picks my team missed on.

Describe the ideal solution
Create a command draft <year> <round>. Output an embed with Year, Round, Birth Overall Pick, Name, Team.

Describe alternatives you've considered
Brute forced the draft api end point on exact matches..

Additional context

...
{
        "year" : 2019,
        "round" : "1",
        "pickOverall" : 1,
        "pickInRound" : 1,
        "team" : {
          "id" : 1,
          "name" : "New Jersey Devils",
          "link" : "/api/v1/teams/1"
        },
        "prospect" : {
          "id" : 76849,
          "fullName" : "Jack Hughes",
          "link" : "/api/v1/draft/prospects/76849"
        }
}
...

chore(Deps): discord.js v13

Please describe the changes this PR makes and why it should be merged:

discord.js v13 makes the switch to Discord API v9! In addition to this, the new major version also includes a bunch of cool new features. Updating from v12 to v13

  • Bump discord.js from v12 to v13

Status

  • Code changes have been tested against the NHL API, or there are no code changes

Semantic versioning classification:

  • This PR changes the app's interface (methods or parameters added)
    • This PR includes breaking changes (methods removed or renamed, parameters moved or removed)
  • This PR only includes non-code changes, like changes to documentation, README, etc.

Add "on pace" stats for player season response.

Is your feature request related to a problem? Please describe.
I lose my shit absolutely, when i can't see what players are on pace for points wise.

Describe the ideal solution
When Calling a player with $p -s Toews, it would be great if it told me what he's on pace for in an 82 game season, points, goals and assists wise. (points/games *82) as the general forumla.

Describe alternatives you've considered
Apathy

Additional context
I think it could just be a single embed, "on pace" with (50-25-75) as the value, or whatever it is.

All-Star game scores doesn't return

Please describe the problem you are having in as much detail as possible:
The package querystring doesn't allow arrays values to be group together in the URL string which isn't compatible with the NHL API.

Include a reproducible code sample here, if possible:

parameters.gameType = ['PR', 'R', 'P', 'A'];
const query = querystring.stringify(parameters);

Further details:

  • nhl-discord-bot version: 0.3.1
  • Node.js version: 12.14.0
  • Operating system: macOS

Priority this issue should have: Low

  • I have also tested the issue on latest master, commit hash:

Add command for game stats

Is your feature request related to a problem? Please describe.
When a game is in-progress game stats.

Describe the ideal solution
Create a command game with -summary, -team, -player, and -recap.

Describe alternatives you've considered
None

Additional context

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ 08:41/2nd  1st   2nd   3rd   T  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ BOS      โ”‚  0  โ”‚  1  โ”‚  2 โ”‚  3  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ CAR      โ”‚  0  โ”‚  0  โ”‚  1 โ”‚  1  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Add video highlights & recaps to game command

Is your feature request related to a problem? Please describe.
As they come available provide links to the goal highlights and game recaps.

Describe the ideal solution
Utilize /feed/live and /content endpoints to access the urls and markdown to display links in the embeds.
Use the following format in this order of priority:

  1. FLASH_1800K_896x504
  2. FLASH_1800K_960X540

Describe alternatives you've considered
Output raw urls in text message.

Additional context

{
    "name" : "FLASH_1800K_960X540",
    "width" : "960",
    "height" : "540",
    "url" : "http://md-akc.med.nhl.com/mp4/nhl/2016/01/28/01656525-73f0-43cd-be30-11149539bca1/1453955452222/asset_1800k.mp4"
} 

YYYY-MM-DD format broken after flags feature introduced

Please describe the problem you are having in as much detail as possible:
#1 introduces a new bug. Passing nhl YYYY-MM-DD for an exact date will fail as it contains hyphens and is read as an unknown flag.

Include a reproducible code sample here, if possible:

const args = message.content.slice(prefix.length).split(/-\S+| /).filter(Boolean);
const flags = (message.content.match(/-([^\s]+)/g) || []).map(f => f.slice(1));

Further details:

  • nhl-discord-bot version: 0.3.1

  • Node.js version: 12.14.0

  • Operating system: macOS

  • Priority this issue should have: Low

  • I have also tested the issue on latest master, commit hash:

Flags error checking doesn't stop execution of NHL command

Please describe the problem you are having in as much detail as possible:
Invalid command execution when an invalid flag is passed. nhl -foobar produces the correct error message but basic nhl command still fires.

Include a reproducible code sample here, if possible:

flags.forEach(flag => {
	if (['tv', 't'].includes(flag)) {
		expands += ',schedule.broadcasts';
		flagBroadcasts = true;
	}
	else if (['venue', 'v'].includes(flag)) {
		flagVenue = true;
	}
	else if (['hide', 'h'].includes(flag)) {
		flagHide = true;
	}
	else {
		return message.channel.send(`\`-${flag}\` is not a valid flag. Type \`${prefix}help nhl\` for list of flags.`);
	}
});

Further details:

  • nhl-discord-bot version: 0.3.0

  • Node.js version: 12.14.0

  • Operating system: macOS

  • Priority this issue should have: High

  • I have also tested the issue on latest master, commit hash:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.