Skip to content

Commit

Permalink
Merge pull request #1433 from Stormbound-Games/plausible-no-more
Browse files Browse the repository at this point in the history
Remove Plausible in favor of Vercel Analytics
  • Loading branch information
KittySparkles authored Oct 13, 2023
2 parents fad9d4d + 16f336e commit 91cc77c
Show file tree
Hide file tree
Showing 36 changed files with 278 additions and 2,019 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Source code for [Stormbound-Kitty](https://stormbound-kitty.com/).
- Hosting: [Vercel](https://vercel.com/) (via an [open-source sponsorship](https://vercel.com/support/articles/can-vercel-sponsor-my-open-source-project))
- Monitoring: [Checkly](https://www.checklyhq.com/)
- Testing: [Jest](https://jestjs.io/) unit tests and [Cypress](https://www.cypress.io/) end-to-end tests (via an [open-source plan](https://docs.cypress.io/guides/dashboard/organizations#Open-Source-Plan))
- Analytics: [Plausible](https://plausible.io/)
- Analytics: [Vercel Analytics](https://vercel.com/analytics)
- URL shortening: [Cutt.ly](https://cutt.ly/) (via an open-source sponsorship)
- CMS: [Sanity](sanity.io/) (via an [open-source plan](https://www.sanity.io/docs/open-source-plan))
- Discord bot hosting: [Heroku](https://www.heroku.com/)
Expand Down
7 changes: 2 additions & 5 deletions bot/commands/abbr/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { SlashCommandBuilder } from 'discord.js'
import toSentence from '#helpers/toSentence'
import getEmbed from '#helpers/getEmbed'
import trackBotCommand from '#helpers/trackBotCommand'

const quotify = value => `“${value}”`

Expand All @@ -13,7 +12,7 @@ const abbr = {
option
.setName('abbr')
.setDescription('The abbreviation to demystify.')
.setRequired(true)
.setRequired(true),
),

async execute(interaction, client) {
Expand All @@ -27,11 +26,9 @@ const abbr = {
.setDescription(
matches
? `“${abbr}” might mean ${toSentence(matches.map(quotify), 'or')}.`
: `Could not find any match for abbreviation “${abbr}”.`
: `Could not find any match for abbreviation “${abbr}”.`,
)

trackBotCommand(interaction, { abbr })

return interaction.reply({ embeds: [embed], ephemeral })
},
}
Expand Down
21 changes: 9 additions & 12 deletions bot/commands/bookodds/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { SlashCommandBuilder } from 'discord.js'
import getDrawingExpectations from '#helpers/getDrawingExpectations'
import getDrawingProbability from '#helpers/getDrawingProbability'
import getEmbed from '#helpers/getEmbed'
import trackBotCommand from '#helpers/trackBotCommand'

const TARGETS = {
FUSION_STONES: 'Fusion Stones',
Expand All @@ -20,33 +19,33 @@ const bookodds = {
data: new SlashCommandBuilder()
.setName('bookodds')
.setDescription(
'Get the odds of drawing a certain card or Fusion stones from a certain book.'
'Get the odds of drawing a certain card or Fusion stones from a certain book.',
)
.addStringOption(option =>
option
.setName('book_type')
.setDescription('The type of book.')
.setRequired(true)
.setAutocomplete(true)
.setAutocomplete(true),
)
.addStringOption(option =>
option
.setName('target')
.setDescription('What you hope to find.')
.addChoices(
...Object.entries(TARGETS).map(([value, name]) => ({ name, value }))
)
...Object.entries(TARGETS).map(([value, name]) => ({ name, value })),
),
),

async autocomplete(interaction, client) {
const focusedValue = interaction.options.getFocused()
const books = [...client.books.values()]
const filtered = books.filter(book =>
book.name.match(new RegExp(focusedValue, 'gi'))
book.name.match(new RegExp(focusedValue, 'gi')),
)

return interaction.respond(
filtered.map(book => ({ name: book.name, value: book.id }))
filtered.map(book => ({ name: book.name, value: book.id })),
)
},

Expand All @@ -60,8 +59,6 @@ const bookodds = {
.setTitle('📕 Book Drawing Odds')
.setURL('https://stormbound-kitty.com/calculators/books')

trackBotCommand(interaction, { book_type: bookId, target })

if (!book) {
embed.setDescription(`Could not find a book matching “${bookId}”.`)

Expand All @@ -74,7 +71,7 @@ const bookodds = {
const odds = book.fsOdds * 100

embed.setDescription(
`A **${book.name}** has ${odds}% chance of drawing **Fusion Stones**.`
`A **${book.name}** has ${odds}% chance of drawing **Fusion Stones**.`,
)

return interaction.reply({ embeds: [embed], ephemeral })
Expand All @@ -87,7 +84,7 @@ const bookodds = {
const odds = (probability * 100).toFixed(2)

embed.setDescription(
`A **${book.name}** has ${odds}% chance of drawing **${TARGETS[target]}**.`
`A **${book.name}** has ${odds}% chance of drawing **${TARGETS[target]}**.`,
)

return interaction.reply({ embeds: [embed], ephemeral })
Expand All @@ -112,7 +109,7 @@ const bookodds = {
const fsOdds = book.fsOdds * 100

embed.setDescription(
`A **${book.name}** has a static ${fsOdds}% chance of drawing **Fusion Stones**, an estimated ${specificOdds}% chance of drawing **a specific card** and an estimated ${anyOdds}% chance of drawing **any card**.`
`A **${book.name}** has a static ${fsOdds}% chance of drawing **Fusion Stones**, an estimated ${specificOdds}% chance of drawing **a specific card** and an estimated ${anyOdds}% chance of drawing **any card**.`,
)

return interaction.reply({ embeds: [embed], ephemeral })
Expand Down
7 changes: 2 additions & 5 deletions bot/commands/cardinfo/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import { SlashCommandBuilder } from 'discord.js'
import searchCards from '#helpers/searchCards'
import getEmbed from '#helpers/getEmbed'
import trackBotCommand from '#helpers/trackBotCommand'

const cardinfo = {
data: new SlashCommandBuilder()
.setName('cardinfo')
.setDescription(
'Get information about the card(s) matching the given search criteria (up to 3 results).'
'Get information about the card(s) matching the given search criteria (up to 3 results).',
)
.addStringOption(option =>
option
.setName('card')
.setDescription('An abbreviation, ID, or approximate name.')
.setRequired(true)
.setRequired(true),
),

// @TODO: add support back for aliases
Expand All @@ -24,8 +23,6 @@ const cardinfo = {
const abbreviations = Object.fromEntries(client.abbreviations)
const [card] = searchCards(cards, abbreviations, input)

trackBotCommand(interaction, { card: input })

if (!card) {
const embed = getEmbed()
.setTitle('⚡️ Card Info')
Expand Down
13 changes: 5 additions & 8 deletions bot/commands/cardvalue/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { SlashCommandBuilder } from 'discord.js'
import getCardValue from '#helpers/getCardValue'
import searchCards from '#helpers/searchCards'
import getEmbed from '#helpers/getEmbed'
import trackBotCommand from '#helpers/trackBotCommand'

const cardvalue = {
data: new SlashCommandBuilder()
Expand All @@ -12,7 +11,7 @@ const cardvalue = {
option
.setName('card')
.setDescription('An abbreviation, ID, or approximate name.')
.setRequired(true)
.setRequired(true),
)
.addIntegerOption(option =>
option
Expand All @@ -23,8 +22,8 @@ const cardvalue = {
{ name: '2', value: 2 },
{ name: '3', value: 3 },
{ name: '4', value: 4 },
{ name: '5', value: 5 }
)
{ name: '5', value: 5 },
),
),

async execute(interaction, client) {
Expand All @@ -37,8 +36,6 @@ const cardvalue = {
.setTitle('⚖️ Card Value')
.setURL('https://stormbound-kitty.com/calculators/value')

trackBotCommand(interaction, { card: input })

if (!card) {
embed.setDescription(`Could not find a card matching “${input}”.`)

Expand All @@ -53,7 +50,7 @@ const cardvalue = {

if (!value) {
embed.setDescription(
`It is not possible to efficiently compute the value of ${card.name}.`
`It is not possible to efficiently compute the value of ${card.name}.`,
)

return interaction.reply({ embeds: [embed], ephemeral })
Expand All @@ -71,7 +68,7 @@ const cardvalue = {
embed
.setDescription(content)
.setURL(
`https://stormbound-kitty.com/calculators/value/${level}${card.id.toLowerCase()}`
`https://stormbound-kitty.com/calculators/value/${level}${card.id.toLowerCase()}`,
)
.addFields([
{ name: 'Minimum', value: min, inline: true },
Expand Down
7 changes: 2 additions & 5 deletions bot/commands/changelog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import searchCards from '#helpers/searchCards'
import parseDate from '#helpers/parseDate'
import getChangesFromCard from '#api/changes/getChangesFromCard'
import { formatPreciseDate } from '#helpers/formatDate'
import trackBotCommand from '#helpers/trackBotCommand'

const groupByDate = (acc, change) => {
if (typeof acc[change.date] === 'undefined') {
Expand All @@ -22,7 +21,7 @@ const changelog = {
option
.setName('card')
.setDescription('An abbreviation, ID, or approximate name.')
.setRequired(true)
.setRequired(true),
),

async execute(interaction, client) {
Expand All @@ -33,8 +32,6 @@ const changelog = {
const [card] = searchCards(cards, abbreviations, input)
const embed = getEmbed().setTitle('🛠 Card Changelog')

trackBotCommand(interaction, { card: input })

if (!card) {
embed
.setURL('https://stormbound-kitty.com/changelog')
Expand All @@ -60,7 +57,7 @@ const changelog = {
.join('\n')

return { name, value }
})
}),
)

return interaction.reply({ embeds: [embed], ephemeral })
Expand Down
9 changes: 3 additions & 6 deletions bot/commands/deckadvice/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import getResolvedCardData from '#helpers/getResolvedCardData'
import serialization from '#helpers/serialization'
import getDeckIDFromURL from '#helpers/getDeckIDFromURL'
import indexArray from '#helpers/indexArray'
import trackBotCommand from '#helpers/trackBotCommand'

const deckadvice = {
data: new SlashCommandBuilder()
Expand All @@ -15,7 +14,7 @@ const deckadvice = {
option
.setName('deck')
.setDescription('A Stormbound-Kitty deck ID or deck URL.')
.setRequired(true)
.setRequired(true),
),

async execute(interaction, client) {
Expand All @@ -24,8 +23,6 @@ const deckadvice = {
const id = getDeckIDFromURL(input)
const embed = getEmbed().setTitle('💎 Deck Advice')

trackBotCommand(interaction, { deck: id })

if (!id) {
embed.setDescription('There was an error evaluating the given deck ID.')

Expand Down Expand Up @@ -53,7 +50,7 @@ const deckadvice = {

if (advice.length === 0) {
embed.setDescription(
'No particular suggestions could be found for that deck. It likely means this is a solid and well balanced deck, so kudos and enjoy playing it!'
'No particular suggestions could be found for that deck. It likely means this is a solid and well balanced deck, so kudos and enjoy playing it!',
)

return interaction.reply({ embeds: [embed], ephemeral })
Expand All @@ -63,7 +60,7 @@ const deckadvice = {
...advice.map(advice => ({
name: advice.name,
value: advice.description,
}))
})),
)

return interaction.reply({ embeds: [embed], ephemeral })
Expand Down
3 changes: 0 additions & 3 deletions bot/commands/fanart/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { SlashCommandBuilder } from 'discord.js'
import getEmbed from '#helpers/getEmbed'
import arrayRandom from '#helpers/arrayRandom'
import trackBotCommand from '#helpers/trackBotCommand'
import getArtworks from '#api/artworks/getArtworks'

const fanart = {
Expand All @@ -15,8 +14,6 @@ const fanart = {
const embed = getEmbed()
const { image, user, date } = arrayRandom(artworks)

trackBotCommand(interaction)

embed
.setTitle('👩‍🎨 Fan-art')
.setURL('https://stormbound-kitty.com/members/' + user.slug)
Expand Down
22 changes: 8 additions & 14 deletions bot/commands/gameid/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import { SlashCommandBuilder } from 'discord.js'
import api from '#helpers/triviapi'
import getEmbed from '#helpers/getEmbed'
import trackBotCommand from '#helpers/trackBotCommand'

const gameid = {
data: new SlashCommandBuilder()
.setName('gameid')
.setDescription(
'Record your Stormbound game ID so people can look it up directly from Discord and add you as friend.'
'Record your Stormbound game ID so people can look it up directly from Discord and add you as friend.',
)
.addStringOption(option =>
option.setName('game_id').setDescription('Your own game ID to record.')
option.setName('game_id').setDescription('Your own game ID to record.'),
)
.addUserOption(option =>
option
.setName('member')
.setDescription('Another player’s game ID to look up.')
.setDescription('Another player’s game ID to look up.'),
),

async execute(interaction, client) {
Expand All @@ -25,11 +24,6 @@ const gameid = {
const guildId = interaction.guildId
const embed = getEmbed().setTitle('🎮 Game ID')

trackBotCommand(interaction, {
game_id: gameId,
member: member ? { id: member?.id, name: member?.name } : null,
})

// If the message looks like a Stormbound game ID, record it as the game ID
// of the message author.
if (gameId) {
Expand All @@ -45,7 +39,7 @@ const gameid = {
embed.setDescription(
error.name === 'AbortError'
? 'It looks like the storage service (jsonbin.org) is not responsive. Try again later!'
: `There was an issue recording your game ID (${gameId}).`
: `There was an issue recording your game ID (${gameId}).`,
)

return interaction.reply({ embeds: [embed], ephemeral })
Expand All @@ -61,7 +55,7 @@ const gameid = {
embed.setDescription(
id
? `${member.username}’s game ID is ${id}.`
: `${member.username}’s game ID is not recorded yet.`
: `${member.username}’s game ID is not recorded yet.`,
)

return interaction.reply({ embeds: [embed], ephemeral })
Expand All @@ -71,7 +65,7 @@ const gameid = {
embed.setDescription(
error.name === 'AbortError'
? 'It looks like the storage service (jsonbin.org) is not responsive. Try again later!'
: `There was an issue finding ${member.username}’s game ID.`
: `There was an issue finding ${member.username}’s game ID.`,
)

return interaction.reply({ embeds: [embed], ephemeral })
Expand All @@ -82,7 +76,7 @@ const gameid = {
const id = await api.getGameId(guildId, interaction.user.id)

embed.setDescription(
id ? `Your game ID is ${id}.` : 'Your game ID is not recorded yet.'
id ? `Your game ID is ${id}.` : 'Your game ID is not recorded yet.',
)

return interaction.reply({ embeds: [embed], ephemeral })
Expand All @@ -92,7 +86,7 @@ const gameid = {
embed.setDescription(
error.name === 'AbortError'
? 'It looks like the storage service (jsonbin.org) is not responsive. Try again later!'
: `There was an issue finding your game ID.`
: `There was an issue finding your game ID.`,
)

return interaction.reply({ embeds: [embed], ephemeral })
Expand Down
Loading

1 comment on commit 91cc77c

@vercel
Copy link

@vercel vercel bot commented on 91cc77c Oct 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

stormbound-kitty – ./

stormbound-kitty-stormbound.vercel.app
stormbound-kitty-git-main-stormbound.vercel.app
stormbound-kitty.com

Please sign in to comment.