Skip to content

Commit

Permalink
fix(tip): render correct user displayname in follow tip (#1579)
Browse files Browse the repository at this point in the history
  • Loading branch information
NguyenHuy1812 authored Jan 12, 2024
1 parent dc7b873 commit 45b6f84
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 37 deletions.
11 changes: 5 additions & 6 deletions src/commands/tip/index/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,18 +398,17 @@ export async function handleFollowTip(i: ButtonInteraction) {
const res = followTipCache.res
const amountApprox = followTipCache.amountApprox

const discordRecipients = await Promise.all(
payload.recipients.map((r: string) => getDiscordRenderableByProfileId(r)),
)
const displayNames = (await i.guild?.members.fetch())
.filter((member: any) => payload.recipients.includes(member?.user?.id))
.map((r: any) => r.displayName)

const recipientsString = discordRecipients.join(", ")
const embed = composeEmbedMessage(null, {
title: `New tip to ${recipientsString}`,
title: `New tip to ${displayNames}`,
description: `
\`Amount. \` ${getEmojiToken(payload.token)} ${payload.amount} ${
payload.token
} ${amountApprox}
\`Receiver. \` ${recipientsString}
\`Receiver. \` ${payload.targets.join(", ")}
\`Message. \` Send money.
`,
color: "#89fa8e",
Expand Down
128 changes: 97 additions & 31 deletions src/types/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ export interface ModelAirdropStatusCount {
status?: string
}

export interface ModelBasePrivacySetting {
custom_settings?: ModelPrivacyCustomSetting[]
general_platform_group?: string
general_target_group?: string
}

export interface ModelChain {
coin_gecko_id?: string
currency?: string
Expand Down Expand Up @@ -301,6 +295,7 @@ export interface ModelGuildUserXP {

export interface ModelJSONNullString {
string?: string

/** Valid is true if String is not NULL */
valid?: boolean
}
Expand Down Expand Up @@ -402,11 +397,6 @@ export interface ModelPayToken {
symbol?: string
}

export interface ModelPrivacyCustomSetting {
platform?: string
target_group?: string
}

export interface ModelProductBotCommand {
code?: string
created_at?: string
Expand Down Expand Up @@ -573,9 +563,8 @@ export interface ModelUserPaymentSetting {

export interface ModelUserPrivacySetting {
profile_id?: string
social_accounts?: ModelBasePrivacySetting
tx?: ModelBasePrivacySetting
wallets?: ModelBasePrivacySetting
show_destination_wallet?: boolean
tx_target_group?: string
}

export interface ModelUserTokenSupportRequest {
Expand Down Expand Up @@ -674,12 +663,6 @@ export interface RequestAssignVerifiedRoleRequest {
user_discord_id: string
}

export interface RequestBasePrivacySetting {
custom_settings?: RequestPrivacyCustomSetting[]
general_platform_group?: string
general_target_group?: string
}

export interface RequestClaimQuestsRewardsRequest {
quest_id?: string
routine?: string
Expand Down Expand Up @@ -914,15 +897,9 @@ export interface RequestPaymentSetting {
tx_limit_settings: RequestTxLimitSetting[]
}

export interface RequestPrivacyCustomSetting {
platform?: string
target_group?: string
}

export interface RequestPrivacySetting {
social_accounts?: RequestBasePrivacySetting
tx?: RequestBasePrivacySetting
wallets?: RequestBasePrivacySetting
show_destination_wallet: boolean
tx_target_group: string
}

export interface RequestRoleReactionRequest {
Expand Down Expand Up @@ -1161,6 +1138,24 @@ export interface ResponseAssetPlatformResponseData {
shortname?: string
}

export interface ResponseAssetToken {
address?: string
chain?: ResponseAssetTokenChain
decimal?: number
icon?: string
id?: string
name?: string
native?: boolean
price?: number
symbol?: string
}

export interface ResponseAssetTokenChain {
name?: string
short_name?: string
type?: string
}

export interface ResponseBinanceFutureAccountPositionResponse {
data?: ResponseBinanceFuturePositionInformation[]
}
Expand Down Expand Up @@ -1188,6 +1183,36 @@ export interface ResponseBinanceFuturePositionInformation {
positions?: ResponseBinanceFuturePositionInfo[]
}

export interface ResponseBinancePositionAmountVos {
amount?: string
amountInBTC?: string
amountInUSDT?: string
asset?: string
}

export interface ResponseBinanceStakingProductPosition {
accrualDays?: number
amount?: string
apy?: string
asset?: string
canReStake?: boolean
canRedeemEarly?: boolean
deliveryDate?: number
duration?: number
interestEndDate?: number
nexInterestPay?: string
nextInterestPayDate?: number
payInterestPeriod?: number
positionId?: number
projectId?: string
purchaseTime?: number
redeemPeriod?: number
rewardAmt?: string
rewardAsset?: string
status?: string
type?: string
}

export interface ResponseChainGasTrackerResponseData {
data?: ResponseGasTrackerResponse
}
Expand Down Expand Up @@ -1233,9 +1258,7 @@ export interface ResponseCoinMarketItemData {
price_change_percentage_24h?: number
price_change_percentage_24h_in_currency?: number
price_change_percentage_7d_in_currency?: number
sparkline_in_7d?: {
price?: number[]
}
sparkline_in_7d?: { price?: number[] }
symbol?: string
}

Expand Down Expand Up @@ -1323,17 +1346,21 @@ export interface ResponseCreateUserTokenSupportRequest {

export interface ResponseDataFilterConfigByReaction {
data?: ResponseRoleReactionResponse

/** page index */
page?: number

/** page size */
size?: number
total?: number
}

export interface ResponseDataListRoleReactionResponse {
data?: ResponseListRoleReactionResponse

/** page index */
page?: number

/** page size */
size?: number
total?: number
Expand Down Expand Up @@ -1392,6 +1419,7 @@ export interface ResponseDiscordGuildResponse {
id?: string
name?: string
owner?: boolean

/** @example 0 */
permissions?: string
}
Expand Down Expand Up @@ -1624,8 +1652,10 @@ export interface ResponseGetInvestListResponse {

export interface ResponseGetLevelRoleConfigsResponse {
data?: ModelGuildConfigLevelRole[]

/** page index */
page?: number

/** page size */
size?: number
total?: number
Expand Down Expand Up @@ -1743,6 +1773,7 @@ export interface ResponseGetTrackingWalletsResponse {

export interface ResponseGetTrendingSearch {
coins?: ResponseGetTrendingSearchCoin[]

/** this field coingecko return empty */
exchanges?: any
}
Expand Down Expand Up @@ -2260,6 +2291,7 @@ export interface ResponseOnchainInvestDataResponse {
export interface ResponsePaginationResponse {
/** page index */
page?: number

/** page size */
size?: number
total?: number
Expand Down Expand Up @@ -2506,6 +2538,27 @@ export interface ResponseUser {
username?: string
}

export interface ResponseUserBalanceCex {
binance?: ResponseWalletAssetData[]
}

export interface ResponseUserBalanceOnchain {
evm?: ResponseWalletAssetData[]
ron?: ResponseWalletAssetData[]
sol?: ResponseWalletAssetData[]
sui?: ResponseWalletAssetData[]
}

export interface ResponseUserBalanceResponse {
cex?: ResponseUserBalanceCex
lastest_snapshot_bals?: string
offchain?: ResponseWalletAssetData[]
onchain?: ResponseUserBalanceOnchain
pnl?: string
summarize?: ResponseWalletAssetData[]
totalUsdAmount?: number
}

export interface ResponseUserFeedbackResponse {
data?: ModelUserFeedback[]
page?: number
Expand All @@ -2521,6 +2574,18 @@ export interface ResponseUserNotificationSettingResponse {
data?: ModelUserNotificationSetting
}

export interface ResponseWalletAssetData {
amount?: string
asset_balance?: number
chain_id?: number
contract_name?: string
contract_symbol?: string
detail_lending?: ResponseBinancePositionAmountVos
detail_staking?: ResponseBinanceStakingProductPosition
token?: ResponseAssetToken
usd_balance?: number
}

export interface UtilPagination {
page?: number
size?: number
Expand All @@ -2529,6 +2594,7 @@ export interface UtilPagination {

export interface UuidNullUUID {
uuid?: string

/** Valid is true if UUID is not NULL */
valid?: boolean
}

0 comments on commit 45b6f84

Please sign in to comment.