Skip to content

Commit

Permalink
fix: add to watchlist from ticker flow
Browse files Browse the repository at this point in the history
  • Loading branch information
tuanddd committed Feb 27, 2024
1 parent f44f50f commit b61bb4e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 25 deletions.
3 changes: 1 addition & 2 deletions src/commands/ticker/index/slash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ export const machineConfig: (
return await addToWatchlistFromTicker(
interaction,
interaction.user.id,
ctx.to,
ctx.baseCoin.id,
ctx,
)
},
showOtherTicker: (_interaction, _ev, ctx) => {
Expand Down
52 changes: 29 additions & 23 deletions src/commands/watchlist/add/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,14 @@ export async function addToWatchlist(i: ButtonInteraction) {
export async function addToWatchlistFromTicker(
i: ButtonInteraction,
userId: string,
symbol: string,
coingeckoId: string,
{ to, baseCoin, ...rest }: Record<string, any>,
) {
if (!i.deferred) await i.deferUpdate().catch(() => null)
const msg = i.message as Message
const data = await addUserWatchlist(
msg,
userId,
symbol.toLowerCase(),
coingeckoId,
to.toLowerCase(),
baseCoin.id,
)
if (!data) return null

Expand All @@ -82,24 +80,32 @@ export async function addToWatchlistFromTicker(
.join(" ")
}

await msg.edit({
attachments: [],
embeds: [
getSuccessEmbed({
title: `${symbolString([symbol])} has been added to the watchlist`,
description: `${getEmoji(
"ANIMATED_POINTING_RIGHT",
true,
)} View watchlist with ${await getSlashCommand(
"wlv",
)} (alias for ${await getSlashCommand("watchlist view")})\n${getEmoji(
"ANIMATED_POINTING_RIGHT",
true,
)} To remove, use ${await getSlashCommand("watchlist remove")}`,
}),
],
components: [],
})
return {
initial: "addWatchList",
context: {
to,
baseCoin,
...rest,
},
msgOpts: {
files: [],
embeds: [
getSuccessEmbed({
title: `${symbolString([to])} has been added to the watchlist`,
description: `${getEmoji(
"ANIMATED_POINTING_RIGHT",
true,
)} View watchlist with ${await getSlashCommand(
"wlv",
)} (alias for ${await getSlashCommand("watchlist view")})\n${getEmoji(
"ANIMATED_POINTING_RIGHT",
true,
)} To remove, use ${await getSlashCommand("watchlist remove")}`,
}),
],
components: [],
},
}
}

export async function addUserWatchlist(
Expand Down

0 comments on commit b61bb4e

Please sign in to comment.