-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding linter and fixing a bunch of misc changed outlined in issue 24
- Loading branch information
Showing
13 changed files
with
973 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import globals from "globals"; | ||
import pluginJs from "@eslint/js"; | ||
|
||
|
||
/** @type {import('eslint').Linter.Config[]} */ | ||
export default [ | ||
{files: ["**/*.js"], languageOptions: {sourceType: "commonjs"}}, | ||
{languageOptions: { globals: globals.node }}, | ||
pluginJs.configs.recommended, | ||
]; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,32 @@ | ||
const { SlashCommandBuilder } = require('discord.js'); | ||
const { BikesTable } = require('../../dbObjects.js'); | ||
const { BikesTable, UsersTable } = require('../../dbObjects.js'); | ||
module.exports = { | ||
data: new SlashCommandBuilder() | ||
.setName('get_all_bikes') | ||
.setDescription('Get all your bikes!'), | ||
async execute(interaction) { | ||
const userId = interaction.user.id; | ||
|
||
try { | ||
// Query the BikesTable to get all bikes for the user | ||
const bikes = await BikesTable.findAll({ where: { userId } }); | ||
|
||
if (bikes.length === 0) { | ||
return await interaction.reply('No bikes found.'); | ||
} | ||
const bikeList = bikes.map(bike => `${bike.name} (${bike.brand} ${bike.model})`).join('\n'); | ||
return await interaction.reply(`Your bikes:\n${bikeList}`); | ||
} catch (error) { | ||
console.error('Error fetching bikes:', error); | ||
return await interaction.reply('There was an error fetching your bikes.'); | ||
} | ||
data: new SlashCommandBuilder() | ||
.setName('get_all_bikes') | ||
.setDescription('Get all your bikes!'), | ||
async execute(interaction) { | ||
const userId = interaction.user.id; | ||
// look up if the user is in the database | ||
try { | ||
const user = await UsersTable.findOne({ where: { userId } }); | ||
if (!user) { | ||
return await interaction.reply({content: 'Please connect your Strava using the /connect_strava command.', ephemeral: true }); | ||
} | ||
} catch (error) { | ||
console.error('Error fetching user:', error); | ||
return await interaction.reply({content: 'There was an error querying data, please check back in a bit.', ephemeral: true }); | ||
} | ||
try { | ||
// Query the BikesTable to get all bikes for the user | ||
const bikes = await BikesTable.findAll({ where: { userId } }); | ||
if (bikes.length === 0) { | ||
return await interaction.reply({content: 'No bikes found! Add a bike by going to https://www.strava.com/settings/gear and adding a bike. Then run /sync_bikes to sync your bikes.', ephemeral: true }); | ||
} | ||
const bikeList = bikes.map(bike => `${bike.name}: ${bike.brand} ${bike.model}. ${Math.round(bike.distance * 0.000621371)} miles. Last waxed on ${bike.lastWaxedDate} at ${Math.round(bike.lastWaxedDistance * 0.000621371)} miles.`).join('\n'); | ||
return await interaction.reply({content: `Your bikes:\n${bikeList}`, ephemeral: true }); | ||
} catch (error) { | ||
console.error('Error fetching bikes:', error); | ||
return await interaction.reply({content: 'There was an error fetching your bikes.', ephemeral: true }); | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.